emit-state
EventEmitter for mutating a single state object.
Inspired by substack/virtual-dom-unidirectional-example.
Installation
npm install emit-state
Usage
var createStateEmitter = var actions = var store = store // Kick off initial actionstore
actions.js
var xhr = moduleexports = type: 'init' { store } type: 'fetchSomethingAsync' { store } type: 'updateItems' { var state = store stateisFetching = false statefetchFailed = false stateitems = items return state } type: 'fetchingSomething' { var state = store stateisFetching = true return state } type: 'fetchFailed' { var state = store stateisFetching = false statefetchFailed = true return state }