File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ const store = new Vuex.Store({ ...options })
175
175
176
176
### subscribe
177
177
178
- - ` subscribe(handler: Function): Function`
178
+ - ` subscribe(handler: Function, options?: Object ): Function`
179
179
180
180
ストアへのミューテーションを購読します。` handler` は、全てのミューテーションの後に呼ばれ、引数として、ミューテーション ディスクリプタとミューテーション後の状態を受け取ります。
181
181
@@ -186,13 +186,19 @@ const store = new Vuex.Store({ ...options })
186
186
})
187
187
` ` `
188
188
189
+ デフォルトでは、新しい ` handler` はチェーンの最後に登録されます。つまり、先に追加された他の ` hanlder` が呼び出された後に実行されます。` prepend: true` を ` options` に設定することで、` handler` をチェーンの最初に登録することができます。
190
+
191
+ ` ` ` js
192
+ store.subscribe(handler, { prepend: true })
193
+ ` ` `
194
+
189
195
購読を停止するには、返された unsubscribe 関数呼び出します。
190
196
191
197
プラグインの中でもっともよく利用されます。[詳細](../ guide/ plugins .md )
192
198
193
199
### subscribeAction
194
200
195
- - ` subscribeAction(handler: Function) `
201
+ - ` subscribeAction(handler: Function, options?: Object): Function `
196
202
197
203
> 2.5 .0 で新規追加
198
204
@@ -205,6 +211,12 @@ const store = new Vuex.Store({ ...options })
205
211
})
206
212
` ` `
207
213
214
+ デフォルトでは、新しい ` handler` はチェーンの最後に登録されます。つまり、先に追加された他の ` hanlder` が呼び出された後に実行されます。` prepend: true` を ` options` に設定することで、` handler` をチェーンの最初に登録することができます。
215
+
216
+ ` ` ` js
217
+ store.subscribeAction(handler, { prepend: true })
218
+ ` ` `
219
+
208
220
購読を停止するには、返された購読解除関数を呼びます。
209
221
210
222
> 3.1 .0 で新規追加
Original file line number Diff line number Diff line change @@ -109,16 +109,27 @@ const logger = createLogger({
109
109
// `mutation` は `{ type, payload }` です
110
110
return mutation .type !== " aBlacklistedMutation"
111
111
},
112
+ actionFilter (action , state ) {
113
+ // `filter` と同等ですが、アクション用です
114
+ // `action` は `{ type, payloed }` です
115
+ return action .type !== " aBlacklistedAction"
116
+ },
112
117
transformer (state ) {
113
118
// ロギングの前に、状態を変換します
114
119
// 例えば、特定のサブツリーのみを返します
115
120
return state .subTree
116
121
},
122
+ actionTransformer (action ) {
123
+ // `mutationTransformer` と同等ですが、アクション用です
124
+ return action .type
125
+ },
117
126
mutationTransformer (mutation ) {
118
127
// ミューテーションは、`{ type, payload }` の形式でログ出力されます
119
128
// 任意の方法でそれをフォーマットできます
120
129
return mutation .type
121
130
},
131
+ logActions: true , // アクションログを出力します。
132
+ logMutations: true , // ミューテーションログを出力します。
122
133
logger: console , // `console` API の実装, デフォルトは `console`
123
134
})
124
135
```
You can’t perform that action at this time.
0 commit comments