immuto-react
Version:
React bindings for Immuto
31 lines (30 loc) • 1.46 kB
TypeScript
/// <reference types="react" />
import { Cursor, ReducerBuilder, ReducerOrProvider, Replace } from "immuto";
export declare type PolymorphicTypeMethods<S, A, P> = {
reduce(state: S, action: A): S;
render(props: P & {
binding: Cursor<S, A>;
}): JSX.Element;
};
export declare type Polymorph<S, A, P> = S & {
polymorphicType: PolymorphicTypeMethods<S, A, P>;
};
export declare function render<S, A, P>(props: P & {
binding: Cursor<Polymorph<S, A, P>, A>;
}): JSX.Element;
export interface PolymorphFactory<S, A, P, DS, DA> {
(init: DS): Polymorph<S, A, P>;
isInstance(possibleInstance: Polymorph<any, any, P>): possibleInstance is Polymorph<DS, DA, P>;
isCursor(possibleCursor: Cursor<Polymorph<any, any, P>, any>): possibleCursor is Cursor<Polymorph<DS, DA, P>, DA>;
}
export interface PolymorphDefinition<S, A, P> {
empty: Polymorph<S, A, P>;
reduce: ReducerBuilder<Polymorph<S, A, P>, A | Replace<Polymorph<S, A, P>>>;
derive<DS, DA>(derivedProvider: ReducerOrProvider<DS & S, DA | A>, derivedRenderer: (props: P & {
binding: Cursor<DS & S, DA | A>;
}) => JSX.Element): PolymorphFactory<S, A, P, DS & S, DA | A>;
polymorphType: Polymorph<S, A, P>;
cursorType: Cursor<Polymorph<S, A, P>, A | Replace<Polymorph<S, A, P>>>;
props<P2>(): PolymorphDefinition<S, A, P2>;
}
export declare function polymorph<S, A>(reducerOrProvider: ReducerOrProvider<S, A>): PolymorphDefinition<S, A, {}>;