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.
Resources
Install
npm i --save send-actionAbout
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
See also
- choo - a frontend framework built from small modules, including
send-action