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.
yarn add fusion-rpc-reduxcreateRPCActionsimport {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}}
const actions: Actions = createRPCActions((rpcId: string));rpcId: string - The RPC method nameactions: {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.
createRPCReducerimport {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);