v0.2.1 fix typings

This commit is contained in:
Josep M Sobrepere 2020-06-10 01:46:22 +02:00
parent a6ae654d0b
commit 2596936dec
4 changed files with 9 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@josepot/react-rxjs",
"version": "0.2.0",
"version": "0.2.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,5 +1,5 @@
{
"version": "0.2.0",
"version": "0.2.1",
"sideEffects": false,
"repository": {
"type": "git",

View File

@ -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,

View File

@ -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()
}