0.1.8 • Published 7 years ago

fusion-plugin-rpc-redux v0.1.8

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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'});
0.1.8

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago