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: docs/store.md
+12-18Lines changed: 12 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The `Store` holds the whole state tree of your application. You need to instantiate it.
4
4
5
-
## Constructor
5
+
## **`constructor(initialState: State)`**
6
6
7
7
#### Arguments
8
8
@@ -22,7 +22,7 @@ const store = new Store({ counter: 0 })
22
22
23
23
## Methods
24
24
25
-
### `getState()`
25
+
### **`getState(): State`**
26
26
27
27
This method returns the current state of the store.
28
28
@@ -40,17 +40,17 @@ const state = store.getState()
40
40
console.log(state.counter===0) // true
41
41
```
42
42
43
-
### `dispatch(reducer)`
43
+
### **`dispatch(reducer: Reducer): State`**
44
44
45
45
Dispatches a reducer.
46
46
47
47
#### Arguments
48
48
49
-
1)**reducer** (*ReducerFunction: State -> State*): That reducer will reduce the state of the store. This takes the current state and returns the next state.
49
+
1)**reducer** (*Reducer: State -> State*): That reducer will reduce the state of the store. This takes the current state and returns the next state.
50
50
51
51
#### Returns
52
52
53
-
(*ReducerFunction*): The final reducer that is made by applying the middlewares - if they are given. If the store does enhanced with middlewares, the `dispatch` method returns the same reducer that was taken as argument.
Middlewares can modify the given reducer, so that is not guaranteed that the `dispatch` returns the original reducer that was taken as argument.
69
+
If you use middlewares, that is not guaranteed that the `dispatch` returns the new state. For example `thunk` middleware modify `dispatch`that it returns the result of delegate function.
Middlewares will be run at dispatching before the store applies the new state of the reducer. The added middlewares are composed by order of addition, so the last added middleware will run first.
104
104
105
105
#### Arguments
106
106
107
-
1)**...middlewares** (*MiddlewareFunction: Store -> Next -> Reducer -> any*): Middlewares as variadic arguments. Middleware functions take the `store` instance, a `next` function and the previous `reducer`. The middleware can provide a new reducer via the `next` function.
107
+
1)**...middlewares** (*Middleware: Store -> Next -> Reducer -> any*): Middlewares as variadic arguments. Middleware functions take the `store` instance, a `next` function and the previous `reducer`. The middleware can provide a new reducer via the `next` function.
108
108
109
109
#### Returns
110
110
@@ -124,10 +124,4 @@ const store = new Store({ counter: 0 }).addMiddleware(logger)
Copy file name to clipboardExpand all lines: docs/thunk.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,7 @@
2
2
3
3
Thunk is a repatch middleware to handle async actions. It is very similar to [redux-thunk](https://www.npmjs.com/package/redux-thunk). Thunk middleware allows you to create reducers that returns a function (delegate). The delegate will be fired at dispatching.
0 commit comments