mirror of
https://github.com/re-rxjs/react-rxjs.git
synced 2025-12-08 18:01:51 +00:00
v0.2.1 fix typings
This commit is contained in:
parent
a6ae654d0b
commit
2596936dec
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@josepot/react-rxjs",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"sideEffects": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -4,16 +4,18 @@ import {
|
||||
BehaviorObservable,
|
||||
} from "./operators/distinct-share-replay"
|
||||
import { ConnectorOptions, defaultConnectorOptions } from "./options"
|
||||
import { useObservable } from "./"
|
||||
import { useObservable, SUSPENSE } from "./"
|
||||
|
||||
export function connectFactoryObservable<
|
||||
I,
|
||||
A extends (number | string | boolean | null)[],
|
||||
O
|
||||
>(
|
||||
getObservable: (...args: A) => Observable<O>,
|
||||
_options?: ConnectorOptions<O>,
|
||||
): [(...args: A) => O | I, (...args: A) => Observable<O>] {
|
||||
): [
|
||||
(...args: A) => Exclude<O, typeof SUSPENSE>,
|
||||
(...args: A) => Observable<O>,
|
||||
] {
|
||||
const options = {
|
||||
...defaultConnectorOptions,
|
||||
..._options,
|
||||
|
||||
@ -29,7 +29,7 @@ const getEnhancedSource = <T>(
|
||||
export const useObservable = <O>(
|
||||
source$: Observable<O>,
|
||||
unsubscribeGraceTime = 200,
|
||||
) => {
|
||||
): Exclude<O, typeof SUSPENSE> => {
|
||||
const [state, setState] = useState<O>(SUSPENSE as any)
|
||||
|
||||
useEffect(() => {
|
||||
@ -44,6 +44,6 @@ export const useObservable = <O>(
|
||||
}, [source$, unsubscribeGraceTime])
|
||||
|
||||
return state !== (SUSPENSE as any)
|
||||
? state
|
||||
? (state as any)
|
||||
: getEnhancedSource(source$, unsubscribeGraceTime).getValue()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user