@@ -19,19 +19,25 @@ yarn add fusion-plugin-rpc-redux-react
19
19
``` js
20
20
// src/main.js
21
21
import App from ' fusion-react' ;
22
- import UniversalEvents from ' fusion-plugin-universal-events' ;
23
- import Redux from ' fusion-plugin-react-redux' ;
24
- import RPC from ' fusion-plugin-rpc-redux-react' ;
22
+ import UniversalEvents , {UniversalEventsToken } from ' fusion-plugin-universal-events' ;
23
+ import Redux , {ReduxToken , ReducerToken } from ' fusion-plugin-react-redux' ;
24
+ import RPC , {RPCToken , RPCHandlersToken } from ' fusion-plugin-rpc-redux-react' ;
25
+ import {FetchToken } from ' fusion-tokens' ;
26
+ import fetch from ' unfetch' ;
25
27
26
28
import reducer from ' ./reducer' ;
27
29
import handlers from ' ./rpc' ;
28
30
29
31
export default () => {
30
32
const app = new App (root);
31
33
32
- const EventEmitter = app .plugin (UniversalEvents, {fetch});
33
- app .plugin (Redux, {reducer});
34
- app .plugin (RPC , __NODE__ ? {handlers, EventEmitter} : {fetch});
34
+ app .register (RPCToken, RPC );
35
+ app .register (UniversalEventsToken, UniversalEvents);
36
+ __NODE__
37
+ ? app .register (RPCHandlersToken, handlers);
38
+ : app .register (FetchToken, fetch);
39
+ app .register (ReduxToken, Redux);
40
+ app .register (ReducerToken, reducer);
35
41
}
36
42
37
43
// src/reducer.js
@@ -89,16 +95,29 @@ To use it, register the `fusion-plugin-react-redux` plugin with `reactorEnhancer
89
95
``` js
90
96
// src/main.js
91
97
import App from ' fusion-react' ;
92
- import Redux from ' fusion-plugin-react-redux' ;
98
+ import Redux, {
99
+ ReduxToken ,
100
+ ReducerToken ,
101
+ EnhancerToken
102
+ } from ' fusion-plugin-react-redux' ;
103
+ import RPC , {RPCToken , RPCHandlersToken } from ' fusion-plugin-rpc-redux-react' ;
104
+ import {FetchToken } from ' fusion-tokens' ;
93
105
import {reactorEnhancer } from ' redux-reactors' ;
106
+ import fetch from ' unfetch' ;
107
+
94
108
import reducer from ' ./redux' ;
95
109
import handlers from ' ./rpc' ;
96
- import fetch from ' unfetch' ;
97
110
98
111
export default () => {
99
112
const app = new App ();
100
- app .plugin (Redux, {reducer, enhancer: reactorEnhancer});
101
- app .plugin (RPC , {handlers, fetch});
113
+
114
+ app .register (ReduxToken, Redux);
115
+ app .register (ReducerToken, reducer);
116
+ app .register (EnhancerToken, reactorEnhancer);
117
+
118
+ app .register (RPCToken, RPC );
119
+ app .register (RPCHandlersToken, handlers);
120
+ app .register (FetchToken, fetch);
102
121
return app;
103
122
}
104
123
@@ -181,6 +200,29 @@ However doing large refactors to the shape of the state tree isn't necessarily a
181
200
182
201
### API
183
202
203
+ #### Dependency registration
204
+
205
+ ``` js
206
+ // src/main.js
207
+ import {RPCHandlersToken } from ' fusion-plugin-rpc' ;
208
+ import UniversalEvents , {UniversalEventsToken } from ' fusion-plugin-universal-events' ;
209
+ import {FetchToken } from ' fusion-tokens' ;
210
+ import Redux , {ReduxToken , ReducerToken } from ' fusion-plugin-react-redux' ;
211
+
212
+ app .register (UniversalEventsToken, UniversalEvents);
213
+ __NODE__
214
+ ? app .register (RPCHandlersToken, handlers);
215
+ : app .register (FetchToken, fetch);
216
+ ```
217
+
218
+ ##### Required dependencies
219
+
220
+ Name | Type | Description
221
+ -|-|-
222
+ ` UniversalEventsToken ` | ` UniversalEvents ` | An event emitter plugin, such as the one provided by [ ` fusion-plugin-universal-events ` ] ( https://github.com/fusionjs/fusion-plugin-universal-events ) .
223
+ ` RPCHandlersToken ` | ` Object<(...args: any) => Promise> ` | A map of server-side RPC method implementations. Server-only.
224
+ ` FetchToken ` | ` (url: string, options: Object) => Promise ` | A [ ` fetch ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API ) implementation. Browser-only.
225
+
184
226
#### ` withRPCRedux `
185
227
186
228
``` js
0 commit comments