Skip to content

Commit 0864211

Browse files
committed
docs: start on 0.4.0 changes
1 parent 8aa242a commit 0864211

File tree

7 files changed

+52
-39
lines changed

7 files changed

+52
-39
lines changed

docs/LANGS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* [English](en/)
2-
* [简体中文](zh-cn/)
3-
* [日本語](ja/)
2+
* [简体中文 (outdated)](zh-cn/)
3+
* [日本語 (outdated)](ja/)

docs/en/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Table of Contents
22

33
- [What is Vuex?](intro.md)
4-
- [Core Concepts](concepts.md)
4+
- [Getting Started](getting-started.md)
5+
- Core Concepts
56
- [State](state.md)
67
- [Mutations](mutations.md)
78
- [Actions](actions.md)

docs/en/concepts.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/en/getting-started.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Getting Started
2+
3+
At the center of every Vuex application is the **store**. A "store" is basically a container that holds your application **state**. There are two things that makes a Vuex store different from a plain global object:
4+
5+
1. Vuex stores are reactive. When Vue components retrieve state from it, they will reactively and efficiently update if the store's state changes.
6+
7+
2. You cannot directly mutate the store's state. The only way to change a store's state is by explicitly dispatching **mutations**. This makes every state change easily track-able, and enables tooling that helps us better understand our applications.
8+
9+
### The Simplest Store
10+
11+
> **NOTE:** We will be using ES2015 syntax for code examples for the rest of the docs. If you haven't picked it up, [you should](https://babeljs.io/docs/learn-es2015/)! The doc also assumes you are already familiar with the concepts discussed in [Building Large-Scale Apps with Vue.js](http://vuejs.org/guide/application.html).
12+
13+
Creating a Vuex store is pretty straightforward - just provide an initial state object, and some mutations:
14+
15+
``` js
16+
import Vuex from 'vuex'
17+
18+
const state = {
19+
count: 0
20+
}
21+
22+
const mutations = {
23+
INCREMENT (state) {
24+
state.count++
25+
}
26+
}
27+
28+
const store = new Vuex.Store({
29+
state,
30+
mutations
31+
})
32+
```
33+
34+
Now, you can access the state object as `store.state`, and trigger a mutation by dispatching its name:
35+
36+
``` js
37+
store.dispatch('INCREMENT')
38+
39+
console.log(store.state.count) // -> 1
40+
```
41+
42+
Again, the reason we are dispatching a mutation instead of changing `store.state.count` directly, is because we want to explicitly track it. This simple convention makes your intention more explicit, so that you can reason about state changes in your app better when reading the code. In addition, this gives us the opportunity to implement tools that can log every mutation, take state snapshots, or even perform time travel debugging.
43+
44+
Now this is just the simplest possible example of what a store is. But Vuex is more than just the store. Next, we will discuss some core concepts in depth: [State](state.md), [Mutations](mutations.md), [Actions](actions.md) and [Getters](getters.md).

docs/en/quickstart.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/ja/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Table of Contents
22

3+
> Note: The Japanese docs are currently for 0.2.x only. For the latest version please see the English docs instead.
4+
35
- [Vuex は何ですか?](intro.md)
46
- [中核概念](concepts.md)
57
- [ステート](state.md)

docs/zh-cn/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Table of Contents
22

3+
> 注意:中文版文档目前只更新到 0.2.x 版本,最新版本的文档请看英文版。
4+
35
- [什么是 Vuex?](intro.md)
46
- [核心概念](concepts.md)
57
- [State](state.md)

0 commit comments

Comments
 (0)