How to use fusion-rpc-redux - 2 common examples

To help you get started, we’ve selected a few fusion-rpc-redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fusionjs / fusionjs / fusion-plugin-rpc-redux-react / src / hoc.js View on Github external
function WithRPCRedux(props: Props) {
      const reactReduxContext = React.useContext(ReactReduxContext);
      const ctx = React.useContext(FusionContext);
      const reduxPlugin = useService(ReduxToken).from(ctx);
      const rpc = useService(RPCToken).from(ctx);
      const wrappedMapStateToParams =
        mapStateToParams &&
        ((state, args) => mapStateToParams(state, args, props));
      const store = reactReduxContext
        ? reactReduxContext.store
        : reduxPlugin.store;
      const handler = createRPCHandler({
        rpcId,
        rpc,
        store,
        actions,
        mapStateToParams: wrappedMapStateToParams,
        transformParams,
      });
      return React.createElement(Component, {...props, [propName]: handler});
    }
    const displayName = Component.displayName || Component.name || 'Anonymous';
github fusionjs / fusionjs / fusion-plugin-rpc-redux-react / src / hoc.js View on Github external
export function withRPCReactor(
  rpcId: string,
  reducers: RPCReducersType,
  {
    propName,
    transformParams,
    mapStateToParams,
  }: {
    propName?: string,
    transformParams?: (params: any) => any,
    mapStateToParams?: (state: any, args?: any, ownProps: Props) => any,
  } = {}
) {
  return withRPCRedux(rpcId, {
    actions: createRPCReactors(rpcId, reducers),
    propName,
    rpcId,
    transformParams,
    mapStateToParams,
  });
}

fusion-rpc-redux

Triggers Redux actions when RPC methods are called

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis

Similar packages