flux-store
A simple store for Flux.
Install
$ npm install flux-store
Usage
var FluxStore = ; // that's us, such metavar myDispatcher = ;var Constants = ; var ActionTypes = ConstantsActionTypes; var Store = FluxStore; moduleexports = Store;
API
onDispatcherAction(payload)
This is the handler for your Dispatcher
's action events.
registerDispatcher(Dispatcher)
This is done automatically when you use extend
to create a store and pass in
a dispatcher
. This connects your Store
to your Dispatcher
and populates
your Store
's dispatchToken
property so Flux stuff (like waitFor
)
continues to work.
emitChange()
This emits a change
event so listeners know that state has changed.
Change listeners
Two functions are included in your new Store
. You'll probably use these in
your React controller-views.
addChangeListener(callback)
You can use this in ControllerView.componentDidMount
like:
{ Store;}
removeChangeListener(callback)
You can use this in ControllerView.componentWillUnmount
like:
{ Store;}
License
MIT
Don't forget
What you make with flux-store
is more important than flux-store
.