@@ -70,7 +70,7 @@ function Example({count, loading, error, increment}) {
7070}
7171
7272const hoc = compose (
73- withRPCRedux ({rpcId : ' increment' } ),
73+ withRPCRedux (' increment' ),
7474 connect (({count, loading, error}) => ({count, loading, error})),
7575);
7676export default hoc (Example);
@@ -79,22 +79,21 @@ export default hoc(Example);
7979### Usage with Reactors
8080
8181``` js
82- // add the reactor enhancer in main.js
82+ // add the reactor enhancer in src/ main.js
8383import {reactorEnhancer } from ' redux-reactors'
8484// ...
8585app .plugin (ReduxPlugin, {reducer, enhancer: reactorEnhancer});
8686
87- // define a reactor
88- import {createRPCReactor } from ' fusion-plugin-rpc-redux-react' ;
89- export const incrementReactor = createRPCReactor (' increment' , {
87+ // define a reactor (src/reactors/increment.js)
88+ import {withRPCReactor } from ' fusion-plugin-rpc-redux-react' ;
89+ export const incrementReactor = withRPCReactor (' increment' , {
9090 start : (state , action ) => ({count: state .count , loading: true , error: ' ' });
9191 success : (state , action ) => ({count: action .payload .count , loading: false , error: ' ' });
9292 failure : (state , action ) => ({count: state .count , loading: false , error: action .payload .error });
9393});
9494
95- // use the higher order component
95+ // use the higher order component (src/components/example.js)
9696import React from ' react' ;
97- import {withRPCReactor } from ' fusion-plugin-rpc-redux-react' ;
9897import {connect } from ' react-redux' ;
9998import {compose } from ' redux' ;
10099import {incrementReactor } from ' ./reactors/increment.js'
@@ -113,7 +112,7 @@ function Example({count, loading, error, increment}) {
113112}
114113
115114const hoc = compose (
116- withRPCRedux ( incrementReactor) ,
115+ incrementReactor,
117116 connect (({count, loading, error}) => ({count, loading, error})),
118117);
119118export default hoc (Example);
@@ -126,12 +125,24 @@ export default hoc(Example);
126125
127126``` js
128127import {withRPCRedux } from ' fusion-plugin-rpc-redux-react' ;
129- const NewComponent = withRPCRedux ({
130- rpcId: ' ' , // required
128+ const NewComponent = withRPCRedux (' rpcId' , {
131129 propName: ' ' , // optional, defaults to rpcId
132130 mapStateToParams : (state ) => ({}), // optional
133131 transformParams (params) => ({}), // optional
134- })Component)
132+ })( Component)
135133```
136134
137135#### ` withRPCReactor `
136+ ``` js
137+ import {withRPCReactor } from ' fusion-plugin-rpc-redux-react' ;
138+ const NewComponent = withRPCReactor (' rpcId' , {
139+ start : (state , action ) => newState, // optional
140+ success : (state , action ) => newState, // optional
141+ failure : (state , action ) => newState, // optional
142+ },
143+ {
144+ propName: ' ' , // optional, defaults to rpcId
145+ mapStateToParams : (state ) => ({}), // optional
146+ transformParams (params) => ({}), // optional
147+ })(Component);
148+ ```
0 commit comments