fusion-rpc-redux
TypeScript icon, indicating that this package has built-in type declarations

2.4.1 • Public • Published

fusion-rpc-redux

Build status

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.


Table of contents


Installation

yarn add fusion-rpc-redux

API

createRPCActions

import {createRPCActions} from 'fusion-rpc-redux';

Creates start, success and failure actions for an RPC method name. Basically, assuming a RPC method named myMethod, it lets you write start({foo: 123}) instead of {type: 'MY_METHOD_START', payload: {foo: 123}}

Types
const actions: Actions = createRPCActions((rpcId: string));
  • rpcId: string - The RPC method name
  • returns actions: {start: (arg:T) => Action<T>, success: (arg:T) => Action<T>, failure: (T) => Action<T>}
type Action<T> = {
  type: string,
  payload: T,
};

For example, if rpcId is doSomething, createRPCActions generates the actions DO_SOMETHING_START, DO_SOMETHING_SUCCESS, and DO_SOMETHING_FAILURE.

createRPCReducer

import {createRPCReducer} from 'fusion-rpc-redux';

Creates a reducer that is composed of reducers that respond to start, success and failure actions.

const reducer: Reducer = createRPCReducer(rpcId: string, {
  start: ?Reducer,
  success: ?Reducer,
  failure: ?Reducer,
}, defaultValue: any);

Readme

Keywords

none

Package Sidebar

Install

npm i fusion-rpc-redux

Weekly Downloads

340

Version

2.4.1

License

MIT

Unpacked Size

290 kB

Total Files

32

Last publish

Collaborators

  • fusion-ci