1.0.0 • Published 5 years ago

cross-state-document-builder v1.0.0

Weekly downloads
5
License
WTFPL
Repository
github
Last release
5 years ago

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
1.0.0

5 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.0

8 years ago