UNPKG

@rxx/worker

Version:

React MVI micro framework.

30 lines (29 loc) 1.03 kB
import { Observable, Subject } from 'rxjs'; import { StateFactory } from './store/store'; import { WorkerPayload } from './worker'; export declare type InitialState<T> = { [P in keyof T]: T[P] extends ((a: any, b: infer X) => any) ? X : any; }; export declare type InitialStateFactory<T> = InitialState<T> | (() => InitialState<T>); export declare function makeApp<T extends { [key: string]: StateFactory<{ view: Observable<any>; [key: string]: Observable<any>; }>; }, X extends { [key: string]: any; }>(apps: T, initialStateFactory: InitialStateFactory<T>, otherProps?: X): StateFactory<{ view: { [P in keyof T]: ReturnType<T[P]>['view']; }; } & { [key: string]: Observable<any>; }>; export declare function run<T extends { [key: string]: StateFactory<{ view: Observable<any>; [key: string]: Observable<any>; }>; }, X extends { [key: string]: any; }>(apps: T, initialStateFactory: InitialStateFactory<T>, otherProps?: X): Subject<WorkerPayload>;