Skip to content

Commit

Permalink
Update STYLE_GUIDE to reflect nextAction methodology
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunsaker committed Jun 12, 2018
1 parent 204bb11 commit 58a1cae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions docs/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ src

We use the [Flux Standard Action](https://github.com/redux-utilities/flux-standard-action) as a standard for our redux actions.

To dispatch actions on sagas, we use a slightly different approach. By attaching the nextAction(s) on the meta prop of each action, we can completely customise and chain our actions on the fly, without having to write more explicit sagas, i.e:

```js
this.props.dispatch({
type: 'getAuth',
meta: {
nextAction: {
type: 'SIGN_IN_USER',
payload: {
...
},
meta: {
nextAction: {
type: 'SET_SYSTEM_MESSAGE',
payload: {
message: 'Sign in successful'
}
}
}
}
}
})
```

## Terminology

Some common terminology that we use.
Expand Down
4 changes: 3 additions & 1 deletion docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ it('renders a SmartImage with offline error', () => {

### Testing sagas

#### Typical types of tests carried out
Don't be alarmed when looking at these tests, there are distinct patterns.

#### Patterns

- Testing the saga without a nextAction and without a response from the api
- Testing the saga without a nextAction and with a response from the api
Expand Down

0 comments on commit 58a1cae

Please sign in to comment.