@typescript-tea/core
Version:
The Elm Architecture for typescript
28 lines • 1.37 kB
TypeScript
import { Cmd } from "./cmd";
import { Sub } from "./sub";
import { Dispatch } from "./dispatch";
import { EffectManager } from "./effect-manager";
/**
* A program represents the root of an application.
* @category Program
*/
export declare type Program<Init, State, Action, View> = {
readonly init: (init: Init) => readonly [State, Cmd<Action>?];
readonly update: (action: Action, state: State) => readonly [State, Cmd<Action>?];
readonly view: (props: {
readonly state: State;
readonly dispatch: Dispatch<Action>;
}) => View;
readonly subscriptions?: (state: State) => Sub<Action> | undefined;
};
/**
* This is the runtime that provides the main loop to run a Program.
* Given a Program and an array of EffectManagers it will start the program
* and progress the state each time the program calls update().
* You can use the returned function to terminate the program.
* @param program This is the program to run.
* @typeParam Init This is the type of the initial value passed to the program's init function.
* @category Program
*/
export declare function run<Init, State, Action, View>(program: Program<Init, State, Action, View>, init: Init, render: (view: View) => void, effectManagers?: ReadonlyArray<EffectManager<string, unknown, unknown>>): () => void;
//# sourceMappingURL=program.d.ts.map