@equinor/fusion-observable
Version:
20 lines (19 loc) • 978 B
TypeScript
import { actionMapper } from './action-mapper';
import { type ActionReducerMapBuilder } from './create-reducer';
import { FlowSubject } from './FlowSubject';
import type { ActionDefinitions, ActionTypes } from './types/actions';
import type { ReducerWithInitialState } from './types/reducers';
export type FlowState<TState, TActions extends ActionDefinitions> = {
subject: FlowSubject<TState, ActionTypes<TActions>>;
actions: TActions;
dispatch: ReturnType<typeof actionMapper<TActions>>;
};
export declare function createState<TState, TActions extends ActionDefinitions>(actions: TActions, reducer_or_builder: ReducerWithInitialState<TState, ActionTypes<TActions>> | {
builder: (builder: ActionReducerMapBuilder<TState>, actions: TActions) => void;
initial: TState | (() => TState);
}): {
subject: FlowSubject<TState, ActionTypes<TActions>>;
actions: TActions;
dispatch: ReturnType<typeof actionMapper<TActions>>;
};
export default createState;