1.2.1 • Published 5 years ago

mobx-multiple-store v1.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

基于 mobx 的多 stroe 管理工具

api doc

StoreHelper

创建 mobx-stroe, 根据 instanceKey 作缓存

属性说明类型
static findOrCreate查找或者创建实例(instanceKey: string, newState?: Object)=> instance
constructor创建实例(state: Object)=> instance

WebAPIStore

继承 StoreHelper

属性说明类型默认值
isFetching请求中booleanfalse
isFulfilled请求完成booleanfalse
isRejected请求失败booleanfalse
error错误对象Errornull
tryFetchData尝试调用 fetchData 方法,isFulfilled 为 true 时不调用FunctionFunction
mergeFetched自动处理 fetching 状态,并自动合并请求结果(handle: Function | Promise) => PromiseFunction
fetching自动处理 fetching 状态(handle: Function | Promise) => PromiseFunction

fetchAction

自动处理 fetching 状态的装饰器,只有在继承了 WebAPIStore 时才有效

class A extends WebAPIStore {
  @fetchAction // 基本用法
  @fetchAction.merge // 自动合并请求结果
  @fetchAction.flow // 异步 action,参考 mobx.flow
  @fetchAction.bound // 绑定 this,参考 mobx.action.bound
  @fetchAction({ bound: true, useFlow: true, autoMerge: true }) // 传递参数, 默认都为 false
  func() {

  }
}

asyncAction

异步 action 装饰器,参考 mobx.flow

observables

绑定多个 mobx.observable

@observables(
  {
    title: '' // observable
  },
  {
    list: [] // observable.ref
  }
)
class A extends WebAPIStore {
}
1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.15

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago