flash-redux v0.0.2
flash-redux
Redux middleware, actions and reducer for managing flash messages.
Based on rails flash etc.
Install
npm install flash-redux --save
How it works
flashNowandflashNextaction creators allow you to add newFlashobjects to your redux store via theflashReducer.clearFlashaction creator allows you to clear thenowarray.flashMiddlewarewatches for a configurable trigger action (e.g.react-router-redux'sLOCATION_CHANGE') and cycles the flash messages, sonextbecomesnow, andnextgets reset to an empty array.How you display the messages is up to you!
API
new Flash(message, [type = 'message'])
constructor functionFlash objects have key, message and type properties.
keyis a unique identifier generated byuuid.message: Stringtype: String : default = 'message'
flashReducer
A reducer function that stores flash messages in now and next keys
flashMiddleware({ cycle })
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'.
flashNow(message, [messageType])
Action creator that adds a Flash object to the now array.
flashNext(message, [messageType])
Action creator that adds a Flash object to the next array.
clearFlash()
Action creator that clears the now array.