Skip to content

Commit

Permalink
docs: update ja docs (vuejs#1497)
Browse files Browse the repository at this point in the history
* docs(ja): update plugin.md

ref: vuejs@3d3e4e0

* docs(ja): update api/README.md

ref: vuejs@be75d41

* docs(ja): translate previous commit

* docs(ja): add link

ref: vuejs@bd23b9a

* docs(ja): update hot-reload.md

ref: vuejs@ee7c6f3

* docs(ja): remove stage-3

ref: vuejs@de05152

* docs(ja): add sentence from en docs

ref: vuejs@095ccc3

* docs(ja): translate previous commit

* docs(ja): add video

* docs(ja): replce component

ref: vuejs@2dfdd83

* docs(ja): add new API docs

ref: vuejs@431540b

* docs(ja): translate previous commit
  • Loading branch information
kazupon authored and ktsn committed Jan 31, 2019
1 parent 85ab92e commit 52fe045
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/ja/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Vuex とは何か?

<VideoPreview />

Vuex は Vue.js アプリケーションのための **状態管理パターン + ライブラリ**です。
これは予測可能な方法によってのみ状態の変異を行うというルールを保証し、アプリケーション内の全てのコンポーネントのための集中型のストアとして機能します。
また Vue 公式の[開発ツール拡張](https://github.com/vuejs/vue-devtools)と連携し、設定なしでタイムトラベルデバッグやステートのスナップショットのエクスポートやインポートのような高度な機能を提供します。
Expand Down
34 changes: 32 additions & 2 deletions docs/ja/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ const store = new Vuex.Store({ ...options })

[詳細](../guide/strict.md)


### devtools

-: `Boolean`

特定の Vuex インスタンスに対して開発ツールをオン、またはオフにします。インスタンスに false を渡すと、開発ツールのプラグインを購読しないように Vuex ストアに伝えます。1 ページに複数のストアがある場合に便利です。

``` js
{
devtools: false
}
```

## Vuex.Store インスタンスプロパティ

### state
Expand Down Expand Up @@ -156,7 +169,7 @@ const store = new Vuex.Store({ ...options })

- **`watch(fn: Function, callback: Function, options?: Object): Function`**

`fn`が返す値をリアクティブに監視し、値が変わった時にコールバックを呼びます。`fn`は最初の引数としてストアのステートを、2番目の引数としてゲッターを受け取ります。 Vue の`vm.$watch`メソッドと同じオプションをオプションのオブジェクトとして受け付けます
`fn`が返す値をリアクティブに監視し、値が変わった時にコールバックを呼びます。`fn`は最初の引数としてストアのステートを、2番目の引数としてゲッターを受け取ります。 [Vue の`vm.$watch`メソッド](https://jp.vuejs.org/v2/api/#watch)と同じオプションをオプションのオブジェクトとして受け付けます

監視を止める場合は、返された unwatch 関数を呼び出します。

Expand Down Expand Up @@ -192,7 +205,24 @@ const store = new Vuex.Store({ ...options })
})
```

 プラグインで最も一般的に使用されます。[Details](../guide/plugins.md)
 購読を停止するには、返された購読解除関数を呼びます。

> 3.1.0 で新規追加

3.1.0 から、`subscribeAction` は購読ハンドラがアクションディスパッチの*前 (before)*、または*後 (after)*に呼びだすべきかどうか(デフォルトの動作は、*before* です)指定することもできます。

``` js
store.subscribeAction({
before: (action, state) => {
console.log(`before action ${action.type}`)
},
after: (action, state) => {
console.log(`after action ${action.type}`)
}
})
```

 プラグインで最も一般的に使用されます。[詳細](../guide/plugins.md)

### registerModule

Expand Down
2 changes: 1 addition & 1 deletion docs/ja/guide/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const store = new Vuex.Store({
})
```

アクションハンドラはストアインスタンスのメソッドやプロパティのセットと同じものを呼び出せるコンテキストオブジェクトを受け取ります。したがって `context.commit` を呼び出すことでミューテーションをコミットできます。あるいは `context.state``context.getters` で、状態やゲッターにアクセスできます。なぜコンテキストオブジェクトがストアインスタンスそのものではないのかは、後ほど[モジュール](modules.md)で説明します。
アクションハンドラはストアインスタンスのメソッドやプロパティのセットと同じものを呼び出せるコンテキストオブジェクトを受け取ります。したがって `context.commit` を呼び出すことでミューテーションをコミットできます。あるいは `context.state``context.getters` で、状態やゲッターにアクセスできます。他のアクションも `context.dispatch` で呼ぶこともできます。なぜコンテキストオブジェクトがストアインスタンスそのものではないのかは、後ほど[モジュール](modules.md)で説明します。

実際にはコードを少しシンプルにするために ES2015 の[引数分割束縛(argument destructuring)](https://github.com/lukehoban/es6features#destructuring)がよく使われます(特に `commit` を複数回呼び出す必要があるとき):

Expand Down
2 changes: 1 addition & 1 deletion docs/ja/guide/hot-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (module.hot) {
// babel 6 のモジュール出力のため、ここでは .default を追加しなければならない
const newActions = require('./actions').default
const newMutations = require('./mutations').default
// 新しいアクションとミューテーションにスワップ
// 新しいモジュールとミューテーションにスワップ
store.hotUpdate({
mutations: newMutations,
modules: {
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/guide/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Vuex ストアの状態は Vue によってリアクティブになっている

- `Vue.set(obj, 'newProp', 123)` を使用する。あるいは

- 全く新しいオブジェクトで既存のオブジェクトを置き換える。例えば、stage-3 の[スプレッドシンタックス(object spread syntax)](https://github.com/sebmarkbage/ecmascript-rest-spread) を使用して、次のように書くことができます:
- 全く新しいオブジェクトで既存のオブジェクトを置き換える。例えば、[スプレッドシンタックス(object spread syntax)](https://github.com/sebmarkbage/ecmascript-rest-spread) を使用して、次のように書くことができます:

``` js
state.obj = { ...state.obj, newProp: 123 }
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/guide/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const store = new Vuex.Store({

プラグインは直接、状態を変更できません。これはコンポーネントに似ています。プラグインはコンポーネント同様に、ミューテーションのコミットによる変更のトリガーだけで状態を変更できます。

ミューテーションのコミットによるストアとデータソースの同期をプラグインで実現できます。 websocket データソースとストアを例にします (これは不自然な例です。実際には、さらに複雑なタスクのために `createPlugin` 関数は、追加でいくつかのオプションを受け取れます):
ミューテーションのコミットによるストアとデータソースの同期をプラグインで実現できます。 websocket データソースとストアを例にします (これは不自然な例です。実際には、さらに複雑なタスクのために `createWebSocketPlugin` 関数は、追加でいくつかのオプションを受け取れます):

``` js
export default function createWebSocketPlugin (socket) {
Expand Down

0 comments on commit 52fe045

Please sign in to comment.