UNPKG

1.14 kBTypeScriptView Raw
1import { Observer, Observable } from "rxjs";
2import { ExtractProps } from "./connect";
3export declare type FunctionPropertyNames<T> = {
4 [K in keyof T]: T[K] extends Function ? K : never;
5}[keyof T];
6export declare type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
7export declare type UnaryFunction<T> = (t: T, ...args: any[]) => any;
8export declare type ActionFunction = (...args: any[]) => any;
9export declare type ActionMap<TComponentOrProps> = {
10 [P in keyof FunctionProperties<ExtractProps<TComponentOrProps>>]?: ActionFunction | Observer<FunctionProperties<ExtractProps<TComponentOrProps>>[P] extends UnaryFunction<infer A> ? A : never>;
11};
12/**
13 * A map specifying which property on the components state should be populated with
14 * the value of the map value (=Observable)
15 *
16 * @example
17 * const map = {
18 * secondsPassed: Observable.interval(1000)
19 * }
20 */
21export declare type UnpackMap<TComponentState> = {
22 [P in keyof TComponentState]?: Observable<TComponentState[P]>;
23};
24export declare function assembleActionProps<TOriginalProps>(actionMap: ActionMap<TOriginalProps>): Partial<TOriginalProps>;