Created
October 6, 2016 00:26
-
-
Save jwarby/eae50cd50a88c67298231c4197efe4a1 to your computer and use it in GitHub Desktop.
A saga for redux-saga which verifies that all actions dispatched to the store follow the Flux Standard Action (https://github.com/acdlite/flux-standard-action) pattern. A warning is shown (only once) for each action which violates the pattern.
This file contains hidden or 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
import { takeEvery } from 'redux-saga' | |
import { isFSA } from 'flux-standard-action' | |
const alreadyWarnedAbout = [] | |
export function* fsaCompliance() { | |
yield* takeEvery('*', function* checkCompliance(action) { | |
const { type } = action | |
if (!isFSA(action) && alreadyWarnedAbout.indexOf(type) === -1) { | |
// eslint-disable-next-line no-console | |
console.warn(`${type} does not conform to the Flux Standard Action pattern`) | |
alreadyWarnedAbout.push(type) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Additional dependencies
flux-standard-action
Notes