@cycle/state
Version:
Wraps your Cycle.js main function with reducer-driven state management
18 lines (17 loc) • 787 B
TypeScript
import { Stream } from 'xstream';
import { MainFn, Reducer } from './types';
import { StateSource } from './StateSource';
export declare type Omit<T, K extends keyof T> = {
[P in Exclude<keyof T, K>]: T[P];
};
export declare type Forbid<T, K extends keyof T> = Omit<T, K> & {
[P in K]?: never;
};
export declare type OSo<T, N extends string> = {
[P in N]: StateSource<T>;
};
export declare type OSi<T, N extends string> = {
[P in N]: Stream<Reducer<T>>;
};
export declare type MainWithState<So extends OSo<T, N>, Si extends OSi<T, N>, T, N extends string> = MainFn<Forbid<So, N>, Omit<Si, N>>;
export declare function withState<So extends OSo<T, N>, Si extends OSi<T, N>, T = any, N extends string = 'state'>(main: MainFn<So, Si>, name?: N): MainWithState<So, Si, T, N>;