Home > @elux/vue-web > BaseModel > getPrivateActions

BaseModel.getPrivateActions() method

获取本模块的私有actions

Signature:

protected getPrivateActions<T extends Record<string, Function>>(actionsMap: T): {
        [K in keyof T]: HandlerToAction<T[K]>;
    } & {
        _initState(state: TModuleState): Action;
        _updateState(subject: string, state: Partial<TModuleState>): Action;
        _loadingState(loadingState: {
            [group: string]: LoadingState;
        }): Action;
    };

Parameters

ParameterTypeDescription
actionsMapT

Returns:

{ [K in keyof T]: HandlerToAction<T[K]>; } & { _initState(state: TModuleState): Action; _updateState(subject: string, state: Partial<TModuleState>): Action; _loadingState(loadingState: { [group: string]: LoadingState; }): Action; }

Remarks

有些action只在本Model内部调用,应将其定义为非public权限,此时将无法通过this.actions调用,可以使用this.getPrivateActions(...)

Example

const privateAction = this.getPrivateActions({renameUser: this.renameUser});
this.dispatch(privateAction.renameUser('jimmy'))