Skip to content

docs(ja): translate new options for the subscribe methods and logger plugin #1728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions docs/ja/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const store = new Vuex.Store({ ...options })

### subscribe

- `subscribe(handler: Function): Function`
- `subscribe(handler: Function, options?: Object): Function`

ストアへのミューテーションを購読します。`handler` は、全てのミューテーションの後に呼ばれ、引数として、ミューテーション ディスクリプタとミューテーション後の状態を受け取ります。

Expand All @@ -186,13 +186,19 @@ const store = new Vuex.Store({ ...options })
})
```

デフォルトでは、新しい `handler` はチェーンの最後に登録されます。つまり、先に追加された他の `hanlder` が呼び出された後に実行されます。`prepend: true` を `options` に設定することで、`handler` をチェーンの最初に登録することができます。

``` js
store.subscribe(handler, { prepend: true })
```

購読を停止するには、返された unsubscribe 関数呼び出します。

プラグインの中でもっともよく利用されます。[詳細](../guide/plugins.md)

### subscribeAction

- `subscribeAction(handler: Function)`
- `subscribeAction(handler: Function, options?: Object): Function`

> 2.5.0 で新規追加

Expand All @@ -205,6 +211,12 @@ const store = new Vuex.Store({ ...options })
})
```

デフォルトでは、新しい `handler` はチェーンの最後に登録されます。つまり、先に追加された他の `hanlder` が呼び出された後に実行されます。`prepend: true` を `options` に設定することで、`handler` をチェーンの最初に登録することができます。

``` js
store.subscribeAction(handler, { prepend: true })
```

 購読を停止するには、返された購読解除関数を呼びます。

> 3.1.0 で新規追加
Expand Down
11 changes: 11 additions & 0 deletions docs/ja/guide/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,27 @@ const logger = createLogger({
// `mutation` は `{ type, payload }` です
return mutation.type !== "aBlacklistedMutation"
},
actionFilter (action, state) {
// `filter` と同等ですが、アクション用です
// `action` は `{ type, payloed }` です
return action.type !== "aBlacklistedAction"
},
transformer (state) {
// ロギングの前に、状態を変換します
// 例えば、特定のサブツリーのみを返します
return state.subTree
},
actionTransformer (action) {
// `mutationTransformer` と同等ですが、アクション用です
return action.type
},
mutationTransformer (mutation) {
// ミューテーションは、`{ type, payload }` の形式でログ出力されます
// 任意の方法でそれをフォーマットできます
return mutation.type
},
logActions: true, // アクションログを出力します。
logMutations: true, // ミューテーションログを出力します。
logger: console, // `console` API の実装, デフォルトは `console`
})
```
Expand Down