0.1.2 • Published 7 years ago

re-atom v0.1.2

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
7 years ago

re-atom logo

A library providing simple Clojure atom-inspired state management (for React)

NPM Version

Installation

npm install --save re-atom

General API

atom(module) => atom

atom(middleware, module) => atom

atom(middleware) => (module) => atom

type Module = { initialState: mixed, actions: { string: (AtomInterface, ...args: Array) => void }, actionGenerators: { string: ActionGenerator }, modules: { string: Module }, }

type ActionGenerator = AtomInterface => ActionType

Middleware functions have the following signature: (next) => (initialState, resetFn, actionFn) => void. The resetFn signature is: (oldState, newState) => void. The actionFn signature is: (scope, actionHandler, params, actionPath) => void.

deref(atom)

swap(atom, xf, ...args)

xf = (oldState, ...args) => newState

reset(atom, newState)

dispatch(atom, action, ...args)

addWatch(atom, watcherFn)

watcherFn = (atom, newState, oldState) => void

removeWatch(atom, watcherFn)

wrapGenerator(genFn, ...args)

React API

<Provider stateAtom={atom}>

connect(mapStateFn, mapActionsFn)

mapStateFn = (state, ownProps) => props mapActionsFn = (atom, ownProps) => actionProps

License

MIT

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago