Home > @elux/vue-web > BaseModel

BaseModel class

Model基类

Signature:

export declare abstract class BaseModel<TModuleState extends ModuleState = {}, TStoreState extends StoreState = {}> implements CommonModel 

Implements: CommonModel

Remarks

Model基类实现了CommonModel,并提供了一些常用的方法

Constructors

ConstructorModifiersDescription
(constructor)(moduleName, store)Constructs a new instance of the BaseModel class

Properties

PropertyModifiersTypeDescription
actionsPickThisActions<this>获取本模块的公开actions
moduleNamestring
stateTModuleState获取模块的状态
storeIStore<TStoreState>所属store,model挂载在store下

Methods

MethodModifiersDescription
_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时触发