Created
February 21, 2018 05:10
-
-
Save jamesplease/7c3081f759c69eabc73f028ee330bac7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```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