Skip to content

Commit 7093085

Browse files
committed
wip
1 parent cc2844b commit 7093085

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010

1111
- Breaking change: remove `rxdart` dependency
1212

13-
## 1.1.0 - Dec 17, 2019
13+
## 1.1.0 - Dec 17, 2019
1414
- Update `rxdart`
1515
- Now support extension methods
1616

17-
## 1.0.1+1 - Oct 7, 2019
17+
## 1.0.1+1 - Oct 7, 2019
1818
- Update dependencies
1919
- Update example
2020

21-
## 1.0.1 - Aug 29, 2019
21+
## 1.0.1 - Aug 29, 2019
2222
- Update dependencies
2323
- Some minor changes
2424

25-
## 1.0.0+1 - Jun 29, 2019
25+
## 1.0.0+1 - Jun 29, 2019
2626
- Only change description
2727

28-
## 1.0.0 - Jun 18, 2019
28+
## 1.0.0 - Jun 18, 2019
2929

3030
- Add the document, README, tests and some changes
3131

32-
## 0.0.9 - May 22, 2019
32+
## 0.0.9 - May 22, 2019
3333

3434
- Initial version, created by Stagehand

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Whenever a `SideEffect` needs to know the current State it can use `GetState` to
7171

7272
## Usage
7373

74-
### Version 2.x: Prefer to use `RxReduxStore` over `ReduxStoreStreamTransformer`, but have same concept as version 1.x.
74+
### Version 2.x: Prefer to use `RxReduxStore` over `ReduxStoreStreamTransformer`, but have same concept as version 1.x
7575

7676
```dart
7777
final store = RxReduxStore(
@@ -87,13 +87,13 @@ store.dispatch(Action(Todo(i, 'Title $i', i.isEven), ActionType.add));
8787
await store.dispose();
8888
```
8989

90-
### Note: below is the documentation for version 1.x, but have same concept as version 2.x.
90+
### Note: below is the documentation for version 1.x, but have same concept as version 2.x
9191

9292
Let's create a simple Redux Store for Pagination: Goal is to display a list of `Persons` on screen.
9393
**For a complete example check [the sample application incl. README](example/README.md)**
9494
but for the sake of simplicity let's stick with this simple "list of persons example":
9595

96-
#### 1. Define `State` and `initialState`:
96+
#### 1. Define `State` and `initialState`
9797

9898
```dart
9999
class State {
@@ -114,7 +114,7 @@ final initialState = State(
114114
);
115115
```
116116

117-
#### 2. Define `Actions`:
117+
#### 2. Define `Actions`
118118

119119
```dart
120120
abstract class Action { }
@@ -143,7 +143,7 @@ class ErrorLoadingNextPageAction implements Action {
143143
}
144144
```
145145

146-
#### 3. Define `SideEffects`:
146+
#### 3. Define `SideEffects`
147147

148148
```dart
149149
// SideEffect is just a type alias for such a function:
@@ -172,7 +172,7 @@ Stream<State> loadNextPageSideEffect (
172172
});
173173
```
174174

175-
#### 4. Define `Reducer`:
175+
#### 4. Define `Reducer`
176176

177177
```dart
178178
// Reducer is just a type alias for a function
@@ -200,7 +200,7 @@ State reducer(State state, Action action) {
200200
}
201201
```
202202

203-
#### 5. Combine all it into one:
203+
#### 5. Combine all it into one
204204

205205
- Using `ReduxStoreStreamTransformer`:
206206

@@ -242,14 +242,14 @@ Action action = ...;
242242
store.dispatch(action);
243243
```
244244

245-
#### 6. More:
245+
#### 6. More details
246246

247247
The [following video](https://youtu.be/M7lx9Y9ANYo) (click on it) illustrates the workflow:
248248

249249
[![RxRedux explanation](https://i.ytimg.com/vi/M7lx9Y9ANYo/hqdefault.jpg?sqp=-oaymwEXCNACELwBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLAqwunKP2_qGE0HYUlquWkFccM5MA)](https://youtu.be/M7lx9Y9ANYo)
250250

251251

252-
0. Let's take a look at the following illustration:
252+
0. Let's take a look at the following illustration:
253253
The blue box is the `View` (think UI).
254254
The `Presenter` or `ViewModel` has not been drawn for the sake of readability but you can think of having such additional layers between View and Redux State Machine.
255255
The yellow box represents a `Store`.
@@ -258,19 +258,19 @@ The pink box is a `SideEffect`
258258
Additionally, a green circle represents `State` and a red circle represents an `Action` (see next step).
259259
On the right you see a UI mock of a mobile app to illustrate UI changes.
260260

261-
1. `NextPageAction` gets triggered from the UI (by scrolling at the end of the list). Every `Action` goes through the `reducer` and all `SideEffects` registered for this type of Action.
261+
1. `NextPageAction` gets triggered from the UI (by scrolling at the end of the list). Every `Action` goes through the `reducer` and all `SideEffects` registered for this type of Action.
262262

263-
2. `Reducer` is not interested in `NextPageAction`. So while `NextPageAction` goes through the reducer, it doesn't change the state.
263+
2. `Reducer` is not interested in `NextPageAction`. So while `NextPageAction` goes through the reducer, it doesn't change the state.
264264

265-
3. `loadNextPageSideEffect` (pink box), however, cares about `NextPageAction`. This is the trigger to run the side-effect.
265+
3. `loadNextPageSideEffect` (pink box), however, cares about `NextPageAction`. This is the trigger to run the side-effect.
266266

267-
4. So `loadNextPageSideEffect` takes `NextPageAction` and starts doing the job and makes the http request to load the next page from backend. Before doing that, this side effect starts with emitting `LoadPageAction`.
267+
4. So `loadNextPageSideEffect` takes `NextPageAction` and starts doing the job and makes the http request to load the next page from backend. Before doing that, this side effect starts with emitting `LoadPageAction`.
268268

269-
5. `Reducer` takes `LoadPageAction` emitted from the side effect and reacts on it by "reducing the state".
269+
5. `Reducer` takes `LoadPageAction` emitted from the side effect and reacts on it by "reducing the state".
270270
This means `Reducer` knows how to react on `LoadPageAction` to compute the new state (showing progress indicator at the bottom of the list).
271271
Please note that the state has changed (highlighted in green) which also results in changing the UI (progress indicator at the end of the list).
272272

273-
6. Once `loadNextPageSideEffect` gets the result back from backend, the side effect emits a new `PageLoadedAction`.
273+
6. Once `loadNextPageSideEffect` gets the result back from backend, the side effect emits a new `PageLoadedAction`.
274274
This Action contains a "payload" - the loaded data.
275275

276276
```dart
@@ -280,7 +280,7 @@ class PageLoadedAction implements Action {
280280
}
281281
```
282282

283-
7. As any other Action `PageLoadedAction` goes through the `Reducer`. The Reducer processes this Action and computes a new state out of it by appending the loaded data to the already existing data (progress bar also is hidden).
283+
7. As any other Action `PageLoadedAction` goes through the `Reducer`. The Reducer processes this Action and computes a new state out of it by appending the loaded data to the already existing data (progress bar also is hidden).
284284

285285
Final remark:
286286
This system allows you to create a plugin in system of `SideEffects` that are highly reusable and specific to do a single use case.

0 commit comments

Comments
 (0)