Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {addRule} from 'redux-ruleset'
- addRule({
- id: 'PING_PONG',
- target:'PING',
- consequence: () => ({ type: 'PONG' }),
- addWhen: function* (next) {
- yield next('START_GAME')
- return 'ADD_RULE'
- },
- addUntil: function* (next) {
- yield next('STOP_GAME')
- return 'RECREATE_RULE'
- }
- })
- // later
- dispatch({ type: 'PING' }) // noting happens
- dispatch({ type: 'START_GAME' })
- dispatch({ type: 'PING' }) // => { type: 'PONG' }
- dispatch({ type: 'STOP_GAME' })
- dispatch({ type: 'PING' }) // noting happens
- dispatch({ type: 'PING' }) // noting happens
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement