Skip to content

Commit

Permalink
doc: added docs for app.replaceModel
Browse files Browse the repository at this point in the history
  • Loading branch information
那达 committed Aug 1, 2018
1 parent ba58c70 commit f2150b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ Register model, view [#Model](#model) for details.

Unregister model.

### `app.replaceModel(model)`

> Only available after `app.start()` got called
Replace an existing model with a new one, comparing by the namespace. If no one matches, add the new one.

After called, old `reducers`, `effects`, `subscription` will be replaced with the new ones, while orginal state will be kept, which means it's useful for HMR.

### `app.router(({ history, app }) => RouterConfig)`

Register router config.
Expand Down Expand Up @@ -344,4 +352,4 @@ Store subscriptions in key/value Object. Subscription is used for subscribing da

`({ dispatch, history }, done) => unlistenFunction`

Notice: if we want to unregister a model with `app.unmodel()`, it's subscriptions must return unsubscribe method.
Notice: if we want to unregister a model with `app.unmodel()` or `app.replaceModel()`, it's subscriptions must return unsubscribe method.
8 changes: 8 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ persistStore(app._store);

取消 model 注册,清理 reducers, effects 和 subscriptions。subscription 如果没有返回 unlisten 函数,使用 `app.unmodel` 会给予警告⚠️。

### `app.replaceModel(model)`

> 只在app.start()之后可用
替换model为新model,清理旧model的reducers, effects 和 subscriptions,但会保留旧的state状态,对于HMR非常有用。subscription 如果没有返回 unlisten 函数,使用 `app.unmodel` 会给予警告⚠️。

如果原来不存在相同namespace的model,那么执行`app.model`操作

### `app.router(({ history, app }) => RouterConfig)`

注册路由表。
Expand Down

0 comments on commit f2150b4

Please sign in to comment.