Redux middleware, actions and reducer for managing flash messages.
Based on rails flash etc.
npm install flash-redux --save
flashNow
andflashNext
action creators allow you to add newFlash
objects to your redux store via theflashReducer
.clearFlash
action creator allows you to clear thenow
array.flashMiddleware
watches for a configurable trigger action (e.g.react-router-redux
'sLOCATION_CHANGE
') and cycles the flash messages, sonext
becomesnow
, andnext
gets reset to an empty array.
How you display the messages is up to you!
constructor function
Flash
objects have key
, message
and type
properties.
key
is a unique identifier generated byuuid
.message
: Stringtype
: String : default = 'message'
A reducer function that stores flash messages in now
and next
keys
Redux middleware that captures an action type and cycles the flashReducer
keys, causing next
to become now
and next
gets reset to an empty array.
The config object should contain a cycle
key with a value of the action type to trigger the cycle event.
Typically this would be something like react-router-redux
's LOCATION_CHANGE
'.
Action creator that adds a Flash
object to the now
array.
Action creator that adds a Flash
object to the next
array.
Action creator that clears the now
array.