UNPKG

typedux

Version:

Slightly adjusted Redux (awesome by default) for TS

13 lines (7 loc) 451 B
import type {ObserverDisposer} from "../store/ObservableStore" export type SelectorSubscriptionListener<R> = (value: R, previousValue?: R) => any export type SelectorFn<S, R> = ((state:S) => R) export type Selector<S, R> = SelectorFn<S, R> & { subscribe(listener: SelectorSubscriptionListener<R>):ObserverDisposer } export type InferredSelector<Sel extends (state: any) => any> = Sel extends (state: infer S) => infer R ? Selector<S,R> : never