import { ComposeMeta, IMetaAction } from '../reducers/MetaReducer'; import { BaseModel, State, StateReturn } from '../models/BaseModel'; import { Action } from 'redux'; import { BaseAsyncAction } from './BaseAsyncAction'; export interface IActionCompose extends Action, IMetaAction { message?: string; loading: boolean; } export interface ComposeSubscriber { when: string; then?: (state: State) => StateReturn; after?: () => void; duration?: number; } export declare class ComposeAction Promise> extends BaseAsyncAction { protected readonly runner: Runner; constructor(model: BaseModel, runner: Runner, fromSubClass?: boolean); /** * Information collected from service * * ```javascript * class TestModel extends Model { * getUser = this.compose((id1: number, id2: number) => { * const result1 = await $api.getAsync({ * uri: `/api/users/${id1}`, * }); * const result2 = await $api.getAsync({ * uri: `/api/users/${id2}`, * }); * * this.changeState((state) => { * state[id1] = result1.response; * state[id2] = result2.response; * }); * }); * } * * const testModel = new TestModel(); * * // Get information * testModel.getUser.meta.message; * // Dispatch action * testModel.getUser(); * ``` */ get meta(): ComposeMeta; /** * @see get meta() * * ```javascript * testModel.getUser.loading; * ``` */ get loading(): boolean; /** * @override */ protected methods(): string[]; protected getters(): string[]; protected action(): Function; /** * For model.subscriptions() */ onSuccess(changeState: NonNullable['then']>): ComposeSubscriber; /** * For model.subscriptions() */ afterSuccess(callback: NonNullable['after']>, duration?: number): ComposeSubscriber; /** * For model.subscriptions() */ onPrepare(changeState: NonNullable['then']>): ComposeSubscriber; /** * For model.subscriptions() */ afterPrepare(callback: NonNullable['after']>, duration?: number): ComposeSubscriber; /** * For model.subscriptions() */ onFail(changeState: NonNullable['then']>): ComposeSubscriber; /** * For model.subscriptions() */ afterFail(callback: NonNullable['after']>, duration?: number): ComposeSubscriber; }