store-emitter
A simple redux-inspired state management library that provides more flexible options for listening to changes.
Example
{ if actiontype === 'example' return example: true } var store = store store
API
createStoreEmitter
Create the store
Parameters
modifier
functioninitialState
[object]
Examples
var createStore = var store =
store
Send an action to the store. Takes a single object parameter. Object must include a type
property with a string value, and can contain any other properties.
Parameters
action
objectaction.type
string
Examples
store.getState
Get the current state of the store
Examples
var state = store
store.initialState
Get the initial state of the store
Examples
var state = store
store.off
Stop listening for changes to the store. Passing just the action type will remove all listeners for that action type.
Parameters
event
string – an action typecallback
[Function] – optional callback
Examples
store
store.on
Listen for changes to the store
Parameters
event
string – an action typecallback
Function
Examples
store store store
store.once
Listen for a single change to the store
Parameters
event
string – an action typecallback
Function
Examples
store
See also
- virtual-app – uses store-emitter as a dependency
- namespace-emitter – is a dependency of store-emitter
- yo-yo.js – a library for building UI components that works well with store-emitter
- minidux – a small alternative to redux that means to be a drop-in replacement