@@ -4,11 +4,18 @@ import useConstant from 'use-constant'
44
55import { RestrictArray } from './type'
66
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 ;
7+ export type InputFactory < State > = ( state$ : Observable < State > ) => Observable < State >
8+ export type InputFactoryWithInputs < State , Inputs > = (
9+ state$ : Observable < State > ,
10+ inputs$ : Observable < RestrictArray < Inputs > > ,
11+ ) => Observable < State >
12+ export function useObservable < State > ( inputFactory : InputFactory < State > ) : State | null
13+ export function useObservable < State > ( inputFactory : InputFactory < State > , initialState : State ) : State
14+ export function useObservable < State , Inputs > (
15+ inputFactory : InputFactoryWithInputs < State , Inputs > ,
16+ initialState : State ,
17+ inputs : RestrictArray < Inputs > ,
18+ ) : State
1219export function useObservable < State , Inputs extends ReadonlyArray < any > > (
1320 inputFactory : InputFactoryWithInputs < State , Inputs > ,
1421 initialState ?: State ,
@@ -27,11 +34,11 @@ export function useObservable<State, Inputs extends ReadonlyArray<any>>(
2734 let output$ : BehaviorSubject < State >
2835 if ( inputs ) {
2936 output$ = ( inputFactory as (
30- inputs$ : Observable < RestrictArray < Inputs > | undefined > ,
3137 state$ : Observable < State | undefined > ,
32- ) => Observable < State > ) ( inputs$ , state$ ) as BehaviorSubject < State >
38+ inputs$ : Observable < RestrictArray < Inputs > | undefined > ,
39+ ) => Observable < State > ) ( state$ , inputs$ ) as BehaviorSubject < State >
3340 } else {
34- output$ = ( inputFactory as unknown as ( state$ : Observable < State | undefined > ) => Observable < State > ) (
41+ output$ = ( ( inputFactory as unknown ) as ( state$ : Observable < State | undefined > ) => Observable < State > ) (
3542 state$ ,
3643 ) as BehaviorSubject < State >
3744 }
0 commit comments