fusion-plugin-rpc-redux

0.1.8 • Public • Published

fusion-plugin-rpc-redux

A collection of helper functions for working with Redux and RPC together

If using RPC from React components, you should use fusion-plugin-rpc-redux-react instead of this package.


Installation

yarn add fusion-plugin-rpc-redux

API

createRPCActions

const {start, success, failure} = createRPCActions('foo');
start('payload') // { type: 'FOO_START', payload: 'payload' }
success('payload') // { type: 'FOO_SUCCESS', payload: 'payload' }
failure('payload') // { type: 'FOO_FAILURE', payload: 'payload' }

createRPCReducer

const reducer = createRPCReducer('foo', {
  start: (state, action) => {}, // optional,
  success: (state, action) => {}, // optional,
  failure: (state, action) => {}, // optional,
});

createRPCReactor

const {reactors, rpcId} = createRPCReactor('foo', {
  start: (state, action) => {}, // optional,
  success: (state, action) => {}, // optional,
  failure: (state, action) => {}, // optional,
});

createRPCHandler

const handler = createRPCHandler({
  store, // required
  rpc, // required
  rpcId, // required
  actions: { // optional
    start: () => ({type: '', payload: ''})
    success: () => ({type: '', payload: ''})
    failure: () => ({type: '', payload: ''})
  },
  mapStateToParams: (state) => {}, // optional
  transformParams: (params) => {} // optional
});
await handler({some:'args'});

Readme

Keywords

none

Package Sidebar

Install

npm i fusion-plugin-rpc-redux

Weekly Downloads

1

Version

0.1.8

License

MIT

Last publish

Collaborators

  • fusion-ci