6
6
- [ createInjectorsEnhancer] [ 2 ]
7
7
- [ Parameters] [ 3 ]
8
8
- [ Examples] [ 4 ]
9
- - [ Injectors ] [ 5 ]
10
- - [ injectReducer ] [ 6 ]
9
+ - [ Managers ] [ 5 ]
10
+ - [ createManager ] [ 6 ]
11
11
- [ Parameters] [ 7 ]
12
12
- [ Examples] [ 8 ]
13
- - [ useInjectReducer ] [ 9 ]
14
- - [ Parameters ] [ 10 ]
15
- - [ Examples ] [ 11 ]
16
- - [ injectSaga ] [ 12 ]
17
- - [ Parameters ] [ 13 ]
18
- - [ Examples ] [ 14 ]
19
- - [ useInjectSaga ] [ 15 ]
20
- - [ Parameters ] [ 16 ]
21
- - [ Examples ] [ 17 ]
22
- - [ Misc ] [ 18 ]
23
- - [ forceReducerReload ] [ 19 ]
13
+ - [ Injectors ] [ 9 ]
14
+ - [ injectReducer ] [ 10 ]
15
+ - [ Parameters ] [ 11 ]
16
+ - [ Examples ] [ 12 ]
17
+ - [ useInjectReducer ] [ 13 ]
18
+ - [ Parameters ] [ 14 ]
19
+ - [ Examples ] [ 15 ]
20
+ - [ injectSaga ] [ 16 ]
21
+ - [ Parameters ] [ 17 ]
22
+ - [ Examples ] [ 18 ]
23
+ - [ useInjectSaga ] [ 19 ]
24
24
- [ Parameters] [ 20 ]
25
25
- [ Examples] [ 21 ]
26
- - [ SagaInjectionModes] [ 22 ]
27
- - [ Properties] [ 23 ]
26
+ - [ Misc] [ 22 ]
27
+ - [ forceReducerReload] [ 23 ]
28
+ - [ Parameters] [ 24 ]
29
+ - [ Examples] [ 25 ]
30
+ - [ SagaInjectionModes] [ 26 ]
31
+ - [ Properties] [ 27 ]
28
32
29
33
## Setup
30
34
@@ -38,9 +42,9 @@ injectors to work properly
38
42
39
43
#### Parameters
40
44
41
- - ` params ` ** [ Object] [ 24 ] **
42
- - ` params.runSaga ` ** [ function] [ 25 ] ** A function that runs a saga. Should usually be ` sagaMiddleware.run `
43
- - ` params.createReducer ` ** [ function] [ 25 ] ** A function that should create and
45
+ - ` params ` ** [ Object] [ 28 ] **
46
+ - ` params.runSaga ` ** [ function] [ 29 ] ** A function that runs a saga. Should usually be ` sagaMiddleware.run `
47
+ - ` params.createReducer ` ** [ function] [ 29 ] ** A function that should create and
44
48
return the root reducer. It's passed the injected reducers as the first
45
49
parameter. These should be added to the root reducer using ` combineReducer `
46
50
or a similar method.
@@ -71,6 +75,33 @@ const store = createStore(
71
75
)
72
76
```
73
77
78
+ ## Managers
79
+
80
+
81
+
82
+
83
+ ### createManager
84
+
85
+ Creates a "manager" component that will inject the provided reducer and saga
86
+ when mounted. It only renders its children after both the reducer and saga
87
+ have been injected. This is the recommended way to use redux-injectors.
88
+
89
+ #### Parameters
90
+
91
+ - ` options ` ** [ Object] [ 28 ] **
92
+ - ` options.name ` ** [ function] [ 29 ] ** The name to give the manager that shows up in the react devtools
93
+ - ` options.key ` ** [ string] [ 30 ] ** The key to inject the reducer under
94
+ - ` options.reducer ` ** [ function] [ 29 ] ** The reducer that will be injected
95
+ - ` options.saga ` ** [ function] [ 29 ] ** The saga that will be injected
96
+
97
+ #### Examples
98
+
99
+ ``` javascript
100
+ const BooksManager = createManager ({ name: " BooksManager" , key: " books" , reducer: booksReducer, saga: booksSaga })
101
+ ```
102
+
103
+ Returns ** ComponentType< ; {children: ReactNode}>** The manager
104
+
74
105
## Injectors
75
106
76
107
@@ -83,9 +114,9 @@ component is instantiated
83
114
84
115
#### Parameters
85
116
86
- - ` params ` ** [ Object] [ 24 ] **
87
- - ` params.key ` ** [ string] [ 26 ] ** The key to inject the reducer under
88
- - ` params.reducer ` ** [ function] [ 25 ] ** The reducer that will be injected
117
+ - ` params ` ** [ Object] [ 28 ] **
118
+ - ` params.key ` ** [ string] [ 30 ] ** The key to inject the reducer under
119
+ - ` params.reducer ` ** [ function] [ 29 ] ** The reducer that will be injected
89
120
90
121
#### Examples
91
122
@@ -105,9 +136,9 @@ A react hook that dynamically injects a reducer when the hook is run
105
136
106
137
#### Parameters
107
138
108
- - ` params ` ** [ Object] [ 24 ] **
109
- - ` params.key ` ** [ string] [ 26 ] ** The key to inject the reducer under
110
- - ` params.reducer ` ** [ function] [ 25 ] ** The reducer that will be injected
139
+ - ` params ` ** [ Object] [ 28 ] **
140
+ - ` params.key ` ** [ string] [ 30 ] ** The key to inject the reducer under
141
+ - ` params.reducer ` ** [ function] [ 29 ] ** The reducer that will be injected
111
142
112
143
#### Examples
113
144
@@ -119,6 +150,8 @@ function BooksManager() {
119
150
}
120
151
```
121
152
153
+ Returns ** [ boolean] [ 31 ] ** flag indicating whether or not the reducer has finished injecting
154
+
122
155
### injectSaga
123
156
124
157
A higher-order component that dynamically injects a saga when the component
@@ -127,13 +160,13 @@ dictate how and when the saga should be injected and ejected
127
160
128
161
#### Parameters
129
162
130
- - ` params ` ** [ Object] [ 24 ] **
131
- - ` params.key ` ** [ string] [ 26 ] ** The key to inject the saga under
132
- - ` params.saga ` ** [ function] [ 25 ] ** The saga that will be injected
133
- - ` params.mode ` ** [ string] [ 26 ] ?** The injection behaviour to use. The default is
163
+ - ` params ` ** [ Object] [ 28 ] **
164
+ - ` params.key ` ** [ string] [ 30 ] ** The key to inject the saga under
165
+ - ` params.saga ` ** [ function] [ 29 ] ** The saga that will be injected
166
+ - ` params.mode ` ** [ string] [ 30 ] ?** The injection behaviour to use. The default is
134
167
` SagaInjectionModes.DAEMON ` which causes the saga to be started on component
135
168
instantiation and never canceled or started again. @see
136
- [ SagaInjectionModes] [ 22 ] for the other possible modes.
169
+ [ SagaInjectionModes] [ 26 ] for the other possible modes.
137
170
138
171
#### Examples
139
172
@@ -153,13 +186,9 @@ A react hook that dynamically injects a saga when the hook is run
153
186
154
187
#### Parameters
155
188
156
- - ` params ` ** [ Object] [ 24 ] **
157
- - ` params.key ` ** [ string] [ 26 ] ** The key to inject the saga under
158
- - ` params.saga ` ** [ function] [ 25 ] ** The saga that will be injected
159
- - ` params.mode ` ** [ string] [ 26 ] ?** The injection behaviour to use. The default is
160
- ` SagaInjectionModes.DAEMON ` which causes the saga to be started on component
161
- instantiation and never canceled or started again. @see
162
- [ SagaInjectionModes] [ 22 ] for the other possible modes.
189
+ - ` params ` ** [ Object] [ 28 ] **
190
+ - ` params.key ` ** [ string] [ 30 ] ** The key to inject the saga under
191
+ - ` params.saga ` ** [ function] [ 29 ] ** The saga that will be injected
163
192
164
193
#### Examples
165
194
@@ -171,6 +200,8 @@ function BooksManager() {
171
200
}
172
201
```
173
202
203
+ Returns ** [ boolean] [ 31 ] ** flag indicating whether or not the saga has finished injecting
204
+
174
205
## Misc
175
206
176
207
@@ -198,15 +229,14 @@ An enum of all the possible saga injection behaviours
198
229
199
230
#### Properties
200
231
201
- - ` RESTART_ON_REMOUNT ` ** [ String] [ 26 ] ** The saga will be started on component instantiation and cancelled with
232
+ - ` RESTART_ON_REMOUNT ` ** [ String] [ 30 ] ** The saga will be started on component instantiation and cancelled with
202
233
` task.cancel() ` on component unmount for improved performance.
203
- - ` DAEMON ` ** [ String] [ 26 ] ** Causes the saga to be started on component instantiation and never canceled
234
+ - ` DAEMON ` ** [ String] [ 30 ] ** Causes the saga to be started on component instantiation and never canceled
204
235
or started again.
205
- - ` ONCE_TILL_UNMOUNT ` ** [ String] [ 26 ] ** Behaves like 'RESTART_ON_REMOUNT' but never runs it again.
206
- - ` COUNTER ` ** [ String] [ 26 ] ** The saga will be mounted similar to 'RESTART_ON_REMOUNT', only difference is that
207
- saga will be mounted only once on first inject, and ejected when all injectors are unmounted.
208
- So this enables you to have multiple injectors with same saga and key, only one instance of saga will run
209
- and enables you to have system that are more similar to widgets
236
+ - ` ONCE_TILL_UNMOUNT ` ** [ String] [ 30 ] ** Behaves like 'RESTART_ON_REMOUNT' but never runs it again.
237
+ - ` COUNTER ` ** [ String] [ 30 ] ** Similar to 'RESTART_ON_REMOUNT' except the
238
+ saga will be mounted only once on first inject and ejected when all injectors are unmounted.
239
+ This enables you to have multiple injectors with the same saga and key and only one instance of the saga will run.
210
240
211
241
[ 1 ] : #setup
212
242
@@ -216,46 +246,56 @@ An enum of all the possible saga injection behaviours
216
246
217
247
[ 4 ] : #examples
218
248
219
- [ 5 ] : #injectors
249
+ [ 5 ] : #managers
220
250
221
- [ 6 ] : #injectreducer
251
+ [ 6 ] : #createmanager
222
252
223
253
[ 7 ] : #parameters-1
224
254
225
255
[ 8 ] : #examples-1
226
256
227
- [ 9 ] : #useinjectreducer
257
+ [ 9 ] : #injectors
228
258
229
- [ 10 ] : #parameters-2
259
+ [ 10 ] : #injectreducer
230
260
231
- [ 11 ] : #examples -2
261
+ [ 11 ] : #parameters -2
232
262
233
- [ 12 ] : #injectsaga
263
+ [ 12 ] : #examples-2
234
264
235
- [ 13 ] : #parameters-3
265
+ [ 13 ] : #useinjectreducer
236
266
237
- [ 14 ] : #examples -3
267
+ [ 14 ] : #parameters -3
238
268
239
- [ 15 ] : #useinjectsaga
269
+ [ 15 ] : #examples-3
240
270
241
- [ 16 ] : #parameters-4
271
+ [ 16 ] : #injectsaga
242
272
243
- [ 17 ] : #examples -4
273
+ [ 17 ] : #parameters -4
244
274
245
- [ 18 ] : #misc
275
+ [ 18 ] : #examples-4
246
276
247
- [ 19 ] : #forcereducerreload
277
+ [ 19 ] : #useinjectsaga
248
278
249
279
[ 20 ] : #parameters-5
250
280
251
281
[ 21 ] : #examples-5
252
282
253
- [ 22 ] : #sagainjectionmodes
283
+ [ 22 ] : #misc
284
+
285
+ [ 23 ] : #forcereducerreload
286
+
287
+ [ 24 ] : #parameters-6
288
+
289
+ [ 25 ] : #examples-6
290
+
291
+ [ 26 ] : #sagainjectionmodes
292
+
293
+ [ 27 ] : #properties
254
294
255
- [ 23 ] : #properties
295
+ [ 28 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
256
296
257
- [ 24 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
297
+ [ 29 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
258
298
259
- [ 25 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
299
+ [ 30 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
260
300
261
- [ 26 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
301
+ [ 31 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
0 commit comments