1
1
import {
2
2
createStore ,
3
3
action ,
4
- unstable_effectOn ,
4
+ effectOn ,
5
5
thunk ,
6
6
thunkOn ,
7
7
actionOn ,
@@ -36,7 +36,7 @@ test('fires when the dependencies change', () => {
36
36
addTodo : action ( ( state , payload ) => {
37
37
state . todos . push ( payload ) ;
38
38
} ) ,
39
- onTodosChanged : unstable_effectOn (
39
+ onTodosChanged : effectOn (
40
40
[ ( state ) => state . todos , ( state ) => state . foo ] ,
41
41
( ) => {
42
42
fired = true ;
@@ -45,7 +45,7 @@ test('fires when the dependencies change', () => {
45
45
} ) ;
46
46
47
47
// ACT
48
- store . getActions ( ) . addTodo ( 'add unstable_effectOn api' ) ;
48
+ store . getActions ( ) . addTodo ( 'add effectOn api' ) ;
49
49
50
50
// ASSERT
51
51
expect ( fired ) . toBe ( true ) ;
@@ -69,7 +69,7 @@ test('does not fire when the dependencies have not changed', () => {
69
69
setFoo : action ( ( state , payload ) => {
70
70
state . foo = payload ;
71
71
} ) ,
72
- onTodosChanged : unstable_effectOn ( [ ( state ) => state . todos ] , ( ) => {
72
+ onTodosChanged : effectOn ( [ ( state ) => state . todos ] , ( ) => {
73
73
fired = true ;
74
74
} ) ,
75
75
} ) ;
@@ -89,7 +89,7 @@ test('fires when store dependency changes', () => {
89
89
setFired : action ( ( state , payload ) => {
90
90
state . fired = payload ;
91
91
} ) ,
92
- onTodosChanged : unstable_effectOn (
92
+ onTodosChanged : effectOn (
93
93
[ ( state , storeState ) => storeState . todos ] ,
94
94
( actions ) => {
95
95
actions . setFired ( true ) ;
@@ -123,7 +123,7 @@ test('it receives the local actions', () => {
123
123
setFired : action ( ( state , payload ) => {
124
124
state . fired = payload ;
125
125
} ) ,
126
- onTodosChanged : unstable_effectOn ( [ ( state ) => state . todos ] , ( actions ) => {
126
+ onTodosChanged : effectOn ( [ ( state ) => state . todos ] , ( actions ) => {
127
127
actions . setFired ( true ) ;
128
128
} ) ,
129
129
} ) ;
@@ -144,7 +144,7 @@ test('it receives the local actions for nested model', () => {
144
144
nested : {
145
145
fired : false ,
146
146
todos : [ ] ,
147
- onTodosChanged : unstable_effectOn ( [ ( state ) => state . todos ] , ( actions ) => {
147
+ onTodosChanged : effectOn ( [ ( state ) => state . todos ] , ( actions ) => {
148
148
actions . setFired ( true ) ;
149
149
} ) ,
150
150
addTodo : action ( ( state , payload ) => {
@@ -153,7 +153,7 @@ test('it receives the local actions for nested model', () => {
153
153
setFired : action ( ( state , payload ) => {
154
154
state . fired = payload ;
155
155
} ) ,
156
- }
156
+ } ,
157
157
} ) ;
158
158
159
159
// ASSERT
@@ -184,12 +184,9 @@ test('change argument is as expected', () => {
184
184
actions . setTwo ( target . payload ) ;
185
185
} ,
186
186
) ,
187
- onStateChanged : unstable_effectOn (
188
- [ ( state ) => state . two ] ,
189
- ( actions , change ) => {
190
- actualChange = change ;
191
- } ,
192
- ) ,
187
+ onStateChanged : effectOn ( [ ( state ) => state . two ] , ( actions , change ) => {
188
+ actualChange = change ;
189
+ } ) ,
193
190
} ) ;
194
191
195
192
// ACT
@@ -216,7 +213,7 @@ test('getState is exposed in helpers', async () => {
216
213
setString : action ( ( state , payload ) => {
217
214
state . string = payload ;
218
215
} ) ,
219
- onStateChanged : unstable_effectOn (
216
+ onStateChanged : effectOn (
220
217
[ ( state ) => state . string ] ,
221
218
( actions , change , { getState } ) => {
222
219
actualState = getState ( ) ;
@@ -245,7 +242,7 @@ test('getStoreState is exposed in helpers', async () => {
245
242
setString : action ( ( state , payload ) => {
246
243
state . string = payload ;
247
244
} ) ,
248
- onStateChanged : unstable_effectOn (
245
+ onStateChanged : effectOn (
249
246
[ ( state ) => state . string ] ,
250
247
( actions , change , { getStoreState } ) => {
251
248
actualStoreState = getStoreState ( ) ;
@@ -276,7 +273,7 @@ test('meta values are exposed in helpers', async () => {
276
273
setString : action ( ( state , payload ) => {
277
274
state . string = payload ;
278
275
} ) ,
279
- onStateChanged : unstable_effectOn (
276
+ onStateChanged : effectOn (
280
277
[ ( state ) => state . string ] ,
281
278
( actions , change , { meta } ) => {
282
279
actualMeta = meta ;
@@ -308,7 +305,7 @@ test('injections are exposed in helpers', async () => {
308
305
setString : action ( ( state , payload ) => {
309
306
state . string = payload ;
310
307
} ) ,
311
- onStateChanged : unstable_effectOn (
308
+ onStateChanged : effectOn (
312
309
[ ( state ) => state . string ] ,
313
310
( actions , change , helpers ) => {
314
311
actualInjections = helpers . injections ;
@@ -338,7 +335,7 @@ test('dispatch is exposed in helpers', async () => {
338
335
setString : action ( ( state , payload ) => {
339
336
state . string = payload ;
340
337
} ) ,
341
- onStateChanged : unstable_effectOn (
338
+ onStateChanged : effectOn (
342
339
[ ( state ) => state . string ] ,
343
340
( actions , change , helpers ) => {
344
341
actualDispatch = helpers . dispatch ;
@@ -363,7 +360,7 @@ test('getStoreActions are exposed in helpers', async () => {
363
360
setString : action ( ( state , payload ) => {
364
361
state . string = payload ;
365
362
} ) ,
366
- onStateChanged : unstable_effectOn (
363
+ onStateChanged : effectOn (
367
364
[ ( state ) => state . string ] ,
368
365
( actions , change , helpers ) => {
369
366
helpers . getStoreActions ( ) . nested . setString ( 'three' ) ;
@@ -391,12 +388,9 @@ test('dispatches actions to represent a succeeded effect', () => {
391
388
setNumber : action ( ( state , payload ) => {
392
389
state . number = payload ;
393
390
} ) ,
394
- onStateChanged : unstable_effectOn (
395
- [ ( state ) => state . string ] ,
396
- ( actions ) => {
397
- actions . setNumber ( 2 ) ;
398
- } ,
399
- ) ,
391
+ onStateChanged : effectOn ( [ ( state ) => state . string ] , ( actions ) => {
392
+ actions . setNumber ( 2 ) ;
393
+ } ) ,
400
394
} ,
401
395
} ;
402
396
const trackActions = trackActionsMiddleware ( ) ;
@@ -448,7 +442,7 @@ describe('errors', () => {
448
442
doAsync : thunk ( ( ) => {
449
443
throw err ;
450
444
} ) ,
451
- onStateChanged : unstable_effectOn (
445
+ onStateChanged : effectOn (
452
446
[ ( state ) => state . string ] ,
453
447
async ( actions , change ) => {
454
448
await actions . doAsync ( change . action . payload ) ;
@@ -504,7 +498,7 @@ test('effects cannot be targetted by actionOn', async () => {
504
498
setString : action ( ( state , payload ) => {
505
499
state . string = payload ;
506
500
} ) ,
507
- onStateChanged : unstable_effectOn ( [ ( state ) => state . string ] , ( ) => {
501
+ onStateChanged : effectOn ( [ ( state ) => state . string ] , ( ) => {
508
502
// do nothing
509
503
} ) ,
510
504
invalidActionOn : actionOn (
@@ -535,7 +529,7 @@ test('effects cannot be targetted by thunkOn', async () => {
535
529
setString : action ( ( state , payload ) => {
536
530
state . string = payload ;
537
531
} ) ,
538
- onStateChanged : unstable_effectOn ( [ ( state ) => state . string ] , ( ) => {
532
+ onStateChanged : effectOn ( [ ( state ) => state . string ] , ( ) => {
539
533
// do nothing
540
534
} ) ,
541
535
invalidThunkOn : actionOn (
@@ -567,7 +561,7 @@ test('synchronous effect with synchronous dispose executes as expected', () => {
567
561
setFoo : action ( ( state , payload ) => {
568
562
state . foo = payload ;
569
563
} ) ,
570
- onFooChange : unstable_effectOn ( [ ( state ) => state . foo ] , ( ) => {
564
+ onFooChange : effectOn ( [ ( state ) => state . foo ] , ( ) => {
571
565
executionId += 1 ;
572
566
executions . push ( { id : executionId , type : 'effect' } ) ;
573
567
return ( ) => {
@@ -601,7 +595,7 @@ test('synchronous effect with asynchronous dispose executes as expected', async
601
595
setFoo : action ( ( state , payload ) => {
602
596
state . foo = payload ;
603
597
} ) ,
604
- onFooChange : unstable_effectOn ( [ ( state ) => state . foo ] , ( ) => {
598
+ onFooChange : effectOn ( [ ( state ) => state . foo ] , ( ) => {
605
599
executionId += 1 ;
606
600
const id = executionId ;
607
601
executions . push ( { id, type : 'effect' } ) ;
0 commit comments