Skip to content

Commit 4bcc96a

Browse files
authored
docs(ja): translate a new options for the subscribe methods and logger plugin (#1728)
1 parent 0bbad8c commit 4bcc96a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

docs/ja/api/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const store = new Vuex.Store({ ...options })
175175

176176
### subscribe
177177

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

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

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

189+
デフォルトでは、新しい `handler` はチェーンの最後に登録されます。つまり、先に追加された他の `hanlder` が呼び出された後に実行されます。`prepend: true``options` に設定することで、`handler` をチェーンの最初に登録することができます。
190+
191+
``` js
192+
store.subscribe(handler, { prepend: true })
193+
```
194+
189195
購読を停止するには、返された unsubscribe 関数呼び出します。
190196

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

193199
### subscribeAction
194200

195-
- `subscribeAction(handler: Function)`
201+
- `subscribeAction(handler: Function, options?: Object): Function`
196202

197203
> 2.5.0 で新規追加
198204

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

214+
デフォルトでは、新しい `handler` はチェーンの最後に登録されます。つまり、先に追加された他の `hanlder` が呼び出された後に実行されます。`prepend: true``options` に設定することで、`handler` をチェーンの最初に登録することができます。
215+
216+
``` js
217+
store.subscribeAction(handler, { prepend: true })
218+
```
219+
208220
 購読を停止するには、返された購読解除関数を呼びます。
209221

210222
> 3.1.0 で新規追加

docs/ja/guide/plugins.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,27 @@ const logger = createLogger({
109109
// `mutation` は `{ type, payload }` です
110110
return mutation.type !== "aBlacklistedMutation"
111111
},
112+
actionFilter (action, state) {
113+
// `filter` と同等ですが、アクション用です
114+
// `action` は `{ type, payloed }` です
115+
return action.type !== "aBlacklistedAction"
116+
},
112117
transformer (state) {
113118
// ロギングの前に、状態を変換します
114119
// 例えば、特定のサブツリーのみを返します
115120
return state.subTree
116121
},
122+
actionTransformer (action) {
123+
// `mutationTransformer` と同等ですが、アクション用です
124+
return action.type
125+
},
117126
mutationTransformer (mutation) {
118127
// ミューテーションは、`{ type, payload }` の形式でログ出力されます
119128
// 任意の方法でそれをフォーマットできます
120129
return mutation.type
121130
},
131+
logActions: true, // アクションログを出力します。
132+
logMutations: true, // ミューテーションログを出力します。
122133
logger: console, // `console` API の実装, デフォルトは `console`
123134
})
124135
```

0 commit comments

Comments
 (0)