@@ -70,7 +70,7 @@ function Example({count, loading, error, increment}) {
70
70
}
71
71
72
72
const hoc = compose (
73
- withRPCRedux ({rpcId : ' increment' } ),
73
+ withRPCRedux (' increment' ),
74
74
connect (({count, loading, error}) => ({count, loading, error})),
75
75
);
76
76
export default hoc (Example);
@@ -79,22 +79,21 @@ export default hoc(Example);
79
79
### Usage with Reactors
80
80
81
81
``` js
82
- // add the reactor enhancer in main.js
82
+ // add the reactor enhancer in src/ main.js
83
83
import {reactorEnhancer } from ' redux-reactors'
84
84
// ...
85
85
app .plugin (ReduxPlugin, {reducer, enhancer: reactorEnhancer});
86
86
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' , {
90
90
start : (state , action ) => ({count: state .count , loading: true , error: ' ' });
91
91
success : (state , action ) => ({count: action .payload .count , loading: false , error: ' ' });
92
92
failure : (state , action ) => ({count: state .count , loading: false , error: action .payload .error });
93
93
});
94
94
95
- // use the higher order component
95
+ // use the higher order component (src/components/example.js)
96
96
import React from ' react' ;
97
- import {withRPCReactor } from ' fusion-plugin-rpc-redux-react' ;
98
97
import {connect } from ' react-redux' ;
99
98
import {compose } from ' redux' ;
100
99
import {incrementReactor } from ' ./reactors/increment.js'
@@ -113,7 +112,7 @@ function Example({count, loading, error, increment}) {
113
112
}
114
113
115
114
const hoc = compose (
116
- withRPCRedux ( incrementReactor) ,
115
+ incrementReactor,
117
116
connect (({count, loading, error}) => ({count, loading, error})),
118
117
);
119
118
export default hoc (Example);
@@ -126,12 +125,24 @@ export default hoc(Example);
126
125
127
126
``` js
128
127
import {withRPCRedux } from ' fusion-plugin-rpc-redux-react' ;
129
- const NewComponent = withRPCRedux ({
130
- rpcId: ' ' , // required
128
+ const NewComponent = withRPCRedux (' rpcId' , {
131
129
propName: ' ' , // optional, defaults to rpcId
132
130
mapStateToParams : (state ) => ({}), // optional
133
131
transformParams (params) => ({}), // optional
134
- })Component)
132
+ })( Component)
135
133
```
136
134
137
135
#### ` 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