JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29
  • Score
    100M100P100Q64931F
  • 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 tiny module for managing state.

npm travis standard conduct

Install

npm install send-action

Minimal example

const state = {
  items: []
}

const actions = {
  setItem (state, data) {
    state.items.push(data)
    return state
  }
}

function onChange (state, action) {
  // render app
  console.log(state, action)
}

const send = createStore({ state, actions, onChange })

send('setItem', { title: 'hi' })

See also

  • choo
    • The early versions of choo used send-action! Now choo uses an event emitter approach for managing state which is very cool yet slightly more verbose than I prefer.
  • unistore - The latest version of send-action looks a little more like unistore than it did before. Some differences of send-action include:
    • the source is not transpiled before publish and sticks to es5
    • state is mutable, so there's no setState function
    • managing action functions is a little simpler
    • not returning state from an action avoids triggering the onChange handler
    • no way to subscribe listeners, only the onChange handler
    • if you use react, you'll have an easier time using unistore as it comes with a Provider component

Contributing

Contributions are welcome! Please read the contributing guidelines first.

Conduct

Help keep this project open and inclusive. Please read and follow the code of conduct

Changelog

Read about the changes to this project in CHANGELOG.md. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Contact

License

MIT