import { RecordOf } from "immutable"; import { ComponentClass } from "react"; import { ConnectedComponent } from "react-redux"; import { Action, Dispatch, Reducer } from "redux"; import { Epic } from "redux-observable"; import { Observable } from "rxjs"; import { Diff } from "utility-types"; export interface Myths { [key: string]: Myth; } export interface MythicAction extends Action { type: string; payload: PROPS; error?: boolean; } export declare type ConnectedComponentProps = { [key in MYTH_NAME]: (payload: MYTH_PROPS) => void; } & { dispatch: Dispatch; } & ADDITIONAL_PROPS; export interface Myth { pkg: PKG; name: NAME; type: string; epics: Epic[]; props: PROPS; state: STATE; action: MythicAction; create: (payload: PROPS) => MythicAction; with: >(partial: DEFINED_PROPS & Partial) => (payload: Diff) => MythicAction; appliesTo: (action: Action) => boolean; reduce?: (state: RecordOf, action: Action) => RecordOf; createConnectedComponent: (componentName: COMPONENT_NAME, cls: ComponentClass>, makeState?: (state: any) => Partial) => ConnectedComponent, COMPONENT_PROPS>; } export interface RootState { __private__: { [key in PKG]: RecordOf; }; } export interface MaybeRootState { __private__?: { [key in PKG]?: RecordOf; }; } export declare type Selector = (state?: STATE) => T; export interface MythicPackage { name: PKG; myths: Myths; state: STATE; initialState: RecordOf; makeStateRecord: (state: STATE) => RecordOf; makeRootEpic: () => Epic; rootReducer: Reducer, MythicAction>; createMyth: (name: NAME) => (definition: MythDefinition) => Myth; createSelector: (selector: Selector) => (state?: MaybeRootState) => T | undefined; testMarbles: (inputMarbles: string, outputMarbles: string, marblesMapToActions: { [key: string]: MythicAction; }, state?: STATE) => void; } export declare type ReducerDefinition = (state: RecordOf, action: MythicAction) => RecordOf | void; export interface MythDefinition { reduce?: ReducerDefinition; thenDispatch?: Array>; andAlso?: Array>; } export declare type EpicFuncDefinition = (action: MythicAction, state: RecordOf, myth: Myth) => Observable; export interface EpicWhenFuncDefinition { when: (action: MythicAction) => boolean; dispatch: EpicFuncDefinition; } export interface PackageDefinition { initialState: STATE; }