Skip to content

Instantly share code, notes, and snippets.

@jamesplease
Created February 21, 2018 05:10
Show Gist options
  • Save jamesplease/7c3081f759c69eabc73f028ee330bac7 to your computer and use it in GitHub Desktop.
Save jamesplease/7c3081f759c69eabc73f028ee330bac7 to your computer and use it in GitHub Desktop.
```js
function reducer(state, action) {
switch (action): {
// ...handle the different `action.type` values here
}
}
```
The plugin for this reducer would look like this:
```js
function plugin(resourceType) {
return function reducer(state, action) {
// Let's make sure this plugin only modifies this slice :)
if (resourceType !== action.resourceType) {
return state;
}
switch (action): {
// ...handle the different `action.type` values here
}
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment