JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 44
  • Score
    100M100P100Q64983F
  • License MIT

simple state management

Package Exports

  • send-action

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (send-action) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

send-action

A simple state container.

npm

Resources

Install

npm i --save send-action

About

send-action is meant to be the smallest, simplest redux-like state management library. The focus is on providing a concise method for triggering actions, and on avoiding complex middleware & development dependencies.

The API is significantly different from redux, but the pattern is similar.

Using send-action you trigger actions, modify state based on those actions, and listen to the changes to render your application.

Minimal example

var sendAction = require('send-action')

/*
* Create send function.
*/
var send = sendAction({
  onaction: function (action, state) {
    // modify the state based on actions
    return state
  },
  onchange: function (action, state, oldstate) {
    // render your application
    console.log(action, state, oldstate)
  },
  state: {}
})

/*
* Send an action to the store
*/
send({ type: 'example' value: 'cool' })

/*
* Alternate `send` syntax
*/
send('example', { value: 'cool' })

Examples with common UI modules

License

MIT