Browse Source

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

Kia King Ishii 5 years ago
parent
commit
4bcc96a4e7
2 changed files with 25 additions and 2 deletions
  1. 14 2
      docs/ja/api/README.md
  2. 11 0
      docs/ja/guide/plugins.md

+ 14 - 2
docs/ja/api/README.md

@@ -175,7 +175,7 @@ const store = new Vuex.Store({ ...options })
 
 
 ### subscribe
 ### subscribe
 
 
-- `subscribe(handler: Function): Function`
+- `subscribe(handler: Function, options?: Object): Function`
 
 
   ストアへのミューテーションを購読します。`handler` は、全てのミューテーションの後に呼ばれ、引数として、ミューテーション ディスクリプタとミューテーション後の状態を受け取ります。
   ストアへのミューテーションを購読します。`handler` は、全てのミューテーションの後に呼ばれ、引数として、ミューテーション ディスクリプタとミューテーション後の状態を受け取ります。
 
 
@@ -186,13 +186,19 @@ const store = new Vuex.Store({ ...options })
   })
   })
   ```
   ```
 
 
+  デフォルトでは、新しい `handler` はチェーンの最後に登録されます。つまり、先に追加された他の `hanlder` が呼び出された後に実行されます。`prepend: true` を `options` に設定することで、`handler` をチェーンの最初に登録することができます。
+
+  ``` js
+  store.subscribe(handler, { prepend: true })
+  ```
+
   購読を停止するには、返された unsubscribe 関数呼び出します。
   購読を停止するには、返された unsubscribe 関数呼び出します。
 
 
   プラグインの中でもっともよく利用されます。[詳細](../guide/plugins.md)
   プラグインの中でもっともよく利用されます。[詳細](../guide/plugins.md)
 
 
 ### subscribeAction
 ### subscribeAction
 
 
-- `subscribeAction(handler: Function)`
+- `subscribeAction(handler: Function, options?: Object): Function`
 
 
   > 2.5.0 で新規追加
   > 2.5.0 で新規追加
 
 
@@ -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 で新規追加
   > 3.1.0 で新規追加

+ 11 - 0
docs/ja/guide/plugins.md

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