Home > @elux/react-taro > BaseModel
BaseModel class
Model基类
Signature:
export declare abstract class BaseModel<TModuleState extends ModuleState = {}, TStoreState extends StoreState = {}> implements CommonModel
Implements: CommonModel
Remarks
Model基类实现了CommonModel,并提供了一些常用的方法
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(moduleName, store) | Constructs a new instance of the BaseModel class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
actions | PickThisActions<this> | 获取本模块的公开actions | |
moduleName | string | ||
state | TModuleState | 获取模块的状态 | |
store | IStore<TStoreState> | 所属store,model挂载在store下 |
Methods
Method | Modifiers | Description |
---|---|---|
_initState(state) | 定义reducer监听moduleName._initState ,用来注入初始状态 | |
_loadingState(loadingState) | 定义reducer监听moduleName._loadingState ,用来注入Loading状态 | |
_updateState(subject, state) | 定义reducer监听moduleName._updateState ,用来合并当前状态 | |
dispatch(action) | 等同于this.store.dispatch(action) | |
getCurrentAction() | 获取当前触发的action.type | |
getPrevState() | 获取本模块路由跳转之前的状态 | |
getPrivateActions(actionsMap) | 获取本模块的私有actions | |
getRootState(type) | 获取Store的全局状态,参见IStore | |
getRouter() | 等于this.store.router | |
onActive() | 当前page被激活时触发 | |
onInactive() | 当前page被变为历史快照时触发 | |
onMount(env) | 被挂载到store时触发 |