Naughty Praying Mantis

    re-atom

    0.1.2 • Public • Published

    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

    Install

    npm i re-atom

    DownloadsWeekly Downloads

    0

    Version

    0.1.2

    License

    Apache-2.0

    Last publish

    Collaborators

    • bwalex