You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: v1/en-us/concepts.md
+12-13Lines changed: 12 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@
12
12
13
13
`type State = any`
14
14
15
-
The state tree of your models. Usually, the state is a javascript object(Technically it can be any type), witch is a immutable data.
15
+
The state tree of your models. Usually, the state is a javascript object(Technically it can be any type), which is a immutable data.
16
16
17
17
In dva, you can access top state tree data by `_store`.
18
18
@@ -25,7 +25,7 @@ console.log(app._store); // top state
25
25
26
26
`type AsyncAction = any`
27
27
28
-
Just like Redux's Action, in dva, action is a plain object that represents an intention to change the state. Actions are the only way to get data into the store. Any data, whether from UI events, network callbacks, or other sources such as WebSockets needs to eventually be dispatched as actions.action.(ps:dispatchis realized trhough props by connecting components.)
28
+
Just like Redux's Action, in dva, action is a plain object that represents an intention to change the state. Actions are the only way to get data into the store. Any data, whether from UI events, network callbacks, or other sources such as WebSockets needs to eventually be dispatched as actions.action.(ps:dispatch is realized through props by connecting components.)
29
29
30
30
```javascript
31
31
dispatch({
@@ -39,7 +39,7 @@ dispatch({
39
39
40
40
A dispatching function (or simply dispatch function) is a function that accepts an action or an async action; it then may or may not dispatch one or more actions to the store.
41
41
42
-
Dispatching function is a function for triggering action, action is the only way to change state, but it just describes an action. while dispatch can be regarded as a way to trigger this action, and Reducer is to describe how to change state.
42
+
Dispatching function is a function for triggering action, action is the only way to change state, but it just describes an action. while dispatch can be regarded as a way to trigger this action, and Reducer is to describe how to change state.
43
43
44
44
```javascript
45
45
dispatch({
@@ -54,23 +54,23 @@ dispatch({
54
54
55
55
Just like Redux's Reducer, a reducer (also called a reducing function) is a function that accepts an accumulation and a value and returns a new accumulation. They are used to reduce a collection of values down to a single value.
56
56
57
-
Reducer's concepets from FP:
57
+
Reducer's concepts from FP:
58
58
59
59
```javascript
60
-
[{x:1},{y:2},{z:3}].reduce(function(prev, next){
61
-
returnObject.assign(prev, next);
60
+
[{x:1},{y:2},{z:3}].reduce(function(prev, next){
61
+
returnObject.assign(prev, next);
62
62
})
63
63
//return {x:1, y:2, z:3}
64
64
```
65
65
66
-
In dva, reducers accumule current model's state. There are some things need to be notice that reducer must be [pure function](https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch3.md) and every caclulated data must be [immutable data](https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch3.md#reasonable).
66
+
In dva, reducers accumulate current model's state. There are some things need to be notice that reducer must be [pure function](https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch3.md) and every calculated data must be [immutable data](https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch3.md#reasonable).
67
67
68
68
### Effect
69
69
70
-
In dva, we use [redux-sagas](http://yelouafi.github.io/redux-saga/) to control asynchronous flow.
70
+
In dva, we use [redux-sagas](http://yelouafi.github.io/redux-saga/) to control asynchronous flow.
71
71
You can learn more in [Mostly adequate guide to FP](https://github.com/MostlyAdequate/mostly-adequate-guide).
72
72
73
-
In our applications, the most well-known side effect is asynchronous operation, it comes from the conception of fuctional programing, it is called side effect because it makes our function impure, and the same input may not result in the same output.
73
+
In our applications, the most well-known side effect is asynchronous operation, it comes from the conception of functional programing, it is called side effect because it makes our function impure, and the same input may not result in the same output.
74
74
75
75
### Subscription
76
76
@@ -93,7 +93,7 @@ app.model({
93
93
94
94
## Router
95
95
96
-
Hereby router usually means frontend router. Because our current app is singel page app, frontend codes are required to control the router logics. Through History API provided by the browser, we can monitor the change of the browser's url, so as to control the router.
96
+
Hereby router usually means frontend router. Because our current app is single page app, frontend codes are required to control the router logics. Through History API provided by the browser, we can monitor the change of the browser's url, so as to control the router.
97
97
98
98
dva provide `router` function to control router, based on [react-router](https://github.com/reactjs/react-router)。
99
99
@@ -108,13 +108,12 @@ app.router(({history}) =>
108
108
109
109
## Route Components
110
110
111
-
In dva, we restrict container components to route componenst, because we use page dimension to design container components.
111
+
In dva, we restrict container components to route components, because we use page dimension to design container components.
112
112
113
-
therefore, almost all connet model componets are route components, route components in `/routes/` directory, presentational Components in `/components/` directory.
113
+
therefore, almost all connected model components are route components, route components in `/routes/` directory, presentational Components in `/components/` directory.
Copy file name to clipboardExpand all lines: v1/en-us/getting-started.md
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Some questions you may ask.
18
18
2. How to organize code after created app?
19
19
3. How to build, deploy and publish after development?
20
20
21
-
And somethins about code organization.
21
+
And somethings about code organization.
22
22
23
23
1. How to write Component?
24
24
1. How to write CSS?
@@ -77,7 +77,7 @@ Open http://localhost:8989/ in browser. If success, you will see a page with "He
77
77
78
78
## Define models
79
79
80
-
When get the task, you should not write code immediatly. But recommend to do state design in `god mode`.
80
+
When get the task, you should not write code immediately. But recommend to do state design in `god mode`.
81
81
82
82
1. design models
83
83
2. design components
@@ -99,7 +99,7 @@ app.model({
99
99
100
100
## Write components
101
101
102
-
After designed model, we start to write component. Recommend to organize Component with [stateless functions](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions). Because we don't need state almostly in dva architecture.
102
+
After designed model, we start to write component. Recommend to organize Component with [stateless functions](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions). Because we don't need state almost in dva architecture.
103
103
104
104
```javascript
105
105
importstylesfrom'./index.less';
@@ -132,7 +132,7 @@ Notice:
132
132
133
133
We need two reducers, `add` and `minus`. Please notice `add` will only be recorded if it's highest.
134
134
135
-
> Notice: `add` and `minus` don't need to add namespace prefix in `count` model. But if outside the model, action must prefix namespace seperated with `/`. e.g. `count/add`.
135
+
> Notice: `add` and `minus` don't need to add namespace prefix in `count` model. But if outside the model, action must prefix namespace separated with `/`. e.g. `count/add`.
136
136
137
137
```diff
138
138
app.model({
@@ -165,7 +165,7 @@ Notice:
165
165
166
166
> Remember `count` and `dispatch` props used in the Component before? Where are them come from?
167
167
168
-
After defined Model and Component, we need to connect them together. After connect, Component can use the data from Model, and Model can receive actions dispatched from Component.
168
+
After define Model and Component, we need to connect them together. After connect, Component can use the data from Model, and Model can receive actions dispatched from Component.
169
169
170
170
In this task, we only need to bind `count` .
171
171
@@ -204,7 +204,7 @@ Refresh page in browser, if success, you will see page below.
204
204
205
205
## Add StyleSheet
206
206
207
-
We define stylesheet in `css modules`, which doesn't have many difference from normal css. Because we have already hooked className in Component, at this moment, we only need to replace `index.less` with follow content:
207
+
We define stylesheet in `css modules`, which doesn't have many differences from normal css. Because we have already hooked className in Component, at this moment, we only need to replace `index.less` with follow content:
208
208
209
209
```css
210
210
.normal {
@@ -276,9 +276,9 @@ Notice:
276
276
277
277
Refresh you browser, if success, it should have all the effects of beginning gif.
278
278
279
-
## Subscribe Keboard Event
279
+
## Subscribe Keyboard Event
280
280
281
-
> After implemented mouse click speed test, how to implement keyboard click speed test?
281
+
> After implemented mouse click speed test, how to implement keyboard click speed test?
282
282
283
283
There is a concept called `Subscription` from dva, which is from [elm 0.17](http://elm-lang.org/blog/farewell-to-frp).
284
284
@@ -416,6 +416,6 @@ After build success, you can find compiled files in `dist` directory.
416
416
417
417
## What's Next
418
418
419
-
After complete this app, do you have answer of all the questions in the begenning? Do you understand ths concepts in dva, like `model`, `router`, `reducers`, `effects` and `subscriptions` ?
419
+
After complete this app, do you have answer of all the questions in the beginning? Do you understand this concepts in dva, like `model`, `router`, `reducers`, `effects` and `subscriptions` ?
420
420
421
-
Next, you can view [dva offical library](https://github.com/dvajs/dva) for more infomation.
421
+
Next, you can view [dva official library](https://github.com/dvajs/dva) for more information.
0 commit comments