@@ -4,20 +4,13 @@ import useConstant from 'use-constant'
44
55import { RestrictArray } from './type'
66
7- export type InputFactory < State , Inputs = undefined > = Inputs extends undefined
8- ? ( state$ : Observable < State > ) => Observable < State >
9- : ( inputs$ : Observable < RestrictArray < Inputs > > , state$ : Observable < State > ) => Observable < State >
10-
11- export function useObservable < State > ( inputFactory : InputFactory < State > ) : State | null
12- export function useObservable < State > ( inputFactory : InputFactory < State > , initialState : State ) : State
13- export function useObservable < State , Inputs > (
14- inputFactory : InputFactory < State , Inputs > ,
15- initialState : State ,
16- inputs : RestrictArray < Inputs > ,
17- ) : State
18-
7+ export type InputFactory < State > = ( state$ : Observable < State > ) => Observable < State > ;
8+ export type InputFactoryWithInputs < State , Inputs > = ( inputs$ : Observable < RestrictArray < Inputs > > , state$ : Observable < State > ) => Observable < State > ;
9+ export function useObservable < State > ( inputFactory : InputFactory < State > ) : State | null ;
10+ export function useObservable < State > ( inputFactory : InputFactory < State > , initialState : State ) : State ;
11+ export function useObservable < State , Inputs > ( inputFactory : InputFactoryWithInputs < State , Inputs > , initialState : State , inputs : RestrictArray < Inputs > ) : State ;
1912export function useObservable < State , Inputs extends ReadonlyArray < any > > (
20- inputFactory : InputFactory < State , Inputs > ,
13+ inputFactory : InputFactoryWithInputs < State , Inputs > ,
2114 initialState ?: State ,
2215 inputs ?: RestrictArray < Inputs > ,
2316) : State | null {
@@ -38,7 +31,7 @@ export function useObservable<State, Inputs extends ReadonlyArray<any>>(
3831 state$ : Observable < State | undefined > ,
3932 ) => Observable < State > ) ( inputs$ , state$ ) as BehaviorSubject < State >
4033 } else {
41- output$ = ( inputFactory as ( state$ : Observable < State | undefined > ) => Observable < State > ) (
34+ output$ = ( inputFactory as unknown as ( state$ : Observable < State | undefined > ) => Observable < State > ) (
4235 state$ ,
4336 ) as BehaviorSubject < State >
4437 }
0 commit comments