cross-state-document-builder
Build a document with a Redux reducer, edited across many abstract-state-router states
Last updated 2 years ago by tehshrike .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cross-state-document-builder 
SYNC missed versions from official npm registry.

cross-state-document-builder

For when you want the user to build documents in an application built with abstract-state-router, but don't want them to be tied to a particular state.

Initialize with a asr-active-state-watcher.


const makeAsrStateWatcher = require('asr-active-state-watcher')
const stateWatcher = makeAsrStateWatcher(stateRouter)

const createDocument = beginWatchingRouter(stateWatcher)


function reducer(state, action) {
	switch(action.type) {
		case 'INCREMENT':
			return {
				num: state.num + 1
			}
		case 'DECREMENT':
			return {
				num: state.num - 1
			}
		default:
			return state
	}
}

const doc = createDocument(reducer, { num: 0 })

// a currently active dom API emits "dispatch" with the action "INCREMENT"

doc.store.getState().num // => 1

doc.finishDocument() // Removes all listeners

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

7 Versions

  • 1.0.0                                ...           2 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |