@@ -808,6 +808,113 @@ void main() {
808
808
await future;
809
809
});
810
810
811
+ test ('select6' , () async {
812
+ final initial = Tuple7 (
813
+ 0 ,
814
+ 1.0 ,
815
+ '' ,
816
+ true ,
817
+ < String > [].build (),
818
+ < String , int > {}.build (),
819
+ < String > {}.build (),
820
+ );
821
+
822
+ final store = RxReduxStore <
823
+ int ,
824
+ Tuple7 <int , double , String , bool , BuiltList <String >,
825
+ BuiltMap <String , int >, BuiltSet <String >>>(
826
+ initialState: initial,
827
+ sideEffects: [],
828
+ reducer: (s, a) {
829
+ switch (a) {
830
+ case 0 :
831
+ return s;
832
+ case 1 :
833
+ return s.withItem1 (s.item1 + a); // [item 1]
834
+ case 2 :
835
+ return s.withItem2 (s.item2 + a); // [item 2]
836
+ case 3 :
837
+ return s.withItem7 (s.item7
838
+ .rebuild ((b) => b.add (a.toString ()))); // ------------
839
+ case 4 :
840
+ return s.withItem3 (s.item3 + a.toString ()); // [item 3]
841
+ case 5 :
842
+ return s.withItem4 (! s.item4); // [item 4]
843
+ case 6 :
844
+ return s.withItem7 (s.item7
845
+ .rebuild ((b) => b.add (a.toString ()))); // ------------
846
+ case 7 :
847
+ return s.withItem5 (
848
+ s.item5.rebuild ((b) => b.add (a.toString ()))); // [item 5]
849
+ case 8 :
850
+ return s
851
+ .withItem6 (s.item6.rebuild ((b) => b['@' ] = a)); // [item 6]
852
+ case 9 :
853
+ return s;
854
+ default :
855
+ throw a;
856
+ }
857
+ },
858
+ );
859
+
860
+ final tuple$ = store.select6 (
861
+ expectAsync1 ((state) => state.item1, count: 8 + 1 ),
862
+ // 8 action causes state changed
863
+ expectAsync1 ((state) => state.item2, count: 8 + 1 ),
864
+ // 8 action causes state changed
865
+ expectAsync1 ((state) => state.item3, count: 8 + 1 ),
866
+ // 8 action causes state changed
867
+ expectAsync1 ((state) => state.item4, count: 8 + 1 ),
868
+ // 8 action causes state changed
869
+ expectAsync1 ((state) => state.item5, count: 8 + 1 ),
870
+ // 8 action causes state changed
871
+ expectAsync1 ((state) => state.item6, count: 8 + 1 ),
872
+ // 8 action causes state changed
873
+ expectAsync6 (
874
+ (int subState1,
875
+ double subState2,
876
+ String subState3,
877
+ bool subState4,
878
+ BuiltList <String > subState5,
879
+ BuiltMap <String , int > subState6) =>
880
+ Tuple6 (subState1, subState2, subState3, subState4, subState5,
881
+ subState6),
882
+ count: 6 + 1 , // inc. calling to produce seed value
883
+ ),
884
+ equals3: (String prev, String next) => prev == next,
885
+ );
886
+
887
+ expect (
888
+ tuple$.value,
889
+ Tuple6 (
890
+ 0 , 1.0 , '' , true , < String > [].build (), < String , int > {}.build ()));
891
+ final future = expectLater (
892
+ tuple$,
893
+ emitsInOrder (< Object > [
894
+ Tuple6 (
895
+ 1 , 1.0 , '' , true , < String > [].build (), < String , int > {}.build ()),
896
+ Tuple6 (
897
+ 1 , 3.0 , '' , true , < String > [].build (), < String , int > {}.build ()),
898
+ Tuple6 (
899
+ 1 , 3.0 , '4' , true , < String > [].build (), < String , int > {}.build ()),
900
+ Tuple6 (1 , 3.0 , '4' , false , < String > [].build (),
901
+ < String , int > {}.build ()),
902
+ Tuple6 (1 , 3.0 , '4' , false , < String > ['7' ].build (),
903
+ < String , int > {}.build ()),
904
+ Tuple6 (1 , 3.0 , '4' , false , < String > ['7' ].build (),
905
+ < String , int > {'@' : 8 }.build ()),
906
+ emitsDone,
907
+ ]),
908
+ );
909
+
910
+ for (var i = 0 ; i <= 9 ; i++ ) {
911
+ i.dispatchTo (store);
912
+ }
913
+ await pumpEventQueue (times: 100 );
914
+ await store.dispose ();
915
+ await future;
916
+ });
917
+
811
918
group ('selectMany' , () {
812
919
test ('~= select2' , () async {
813
920
final store = RxReduxStore <int , _State >(
@@ -1184,6 +1291,115 @@ void main() {
1184
1291
await store.dispose ();
1185
1292
await future;
1186
1293
});
1294
+
1295
+ test ('~= select6' , () async {
1296
+ final initial = Tuple7 (
1297
+ 0 ,
1298
+ 1.0 ,
1299
+ '' ,
1300
+ true ,
1301
+ < String > [].build (),
1302
+ < String , int > {}.build (),
1303
+ < String > {}.build (),
1304
+ );
1305
+
1306
+ final store = RxReduxStore <
1307
+ int ,
1308
+ Tuple7 <int , double , String , bool , BuiltList <String >,
1309
+ BuiltMap <String , int >, BuiltSet <String >>>(
1310
+ initialState: initial,
1311
+ sideEffects: [],
1312
+ reducer: (s, a) {
1313
+ switch (a) {
1314
+ case 0 :
1315
+ return s;
1316
+ case 1 :
1317
+ return s.withItem1 (s.item1 + a); // [item 1]
1318
+ case 2 :
1319
+ return s.withItem2 (s.item2 + a); // [item 2]
1320
+ case 3 :
1321
+ return s.withItem7 (s.item7
1322
+ .rebuild ((b) => b.add (a.toString ()))); // ------------
1323
+ case 4 :
1324
+ return s.withItem3 (s.item3 + a.toString ()); // [item 3]
1325
+ case 5 :
1326
+ return s.withItem4 (! s.item4); // [item 4]
1327
+ case 6 :
1328
+ return s.withItem7 (s.item7
1329
+ .rebuild ((b) => b.add (a.toString ()))); // ------------
1330
+ case 7 :
1331
+ return s.withItem5 (
1332
+ s.item5.rebuild ((b) => b.add (a.toString ()))); // [item 5]
1333
+ case 8 :
1334
+ return s.withItem6 (
1335
+ s.item6.rebuild ((b) => b['@' ] = a)); // [item 6]
1336
+ case 9 :
1337
+ return s;
1338
+ default :
1339
+ throw a;
1340
+ }
1341
+ },
1342
+ );
1343
+
1344
+ final tuple$ = store.selectMany (
1345
+ [
1346
+ expectAsync1 ((state) => state.item1, count: 8 + 1 ),
1347
+ // 8 action causes state changed
1348
+ expectAsync1 ((state) => state.item2, count: 8 + 1 ),
1349
+ // 8 action causes state changed
1350
+ expectAsync1 ((state) => state.item3, count: 8 + 1 ),
1351
+ // 8 action causes state changed
1352
+ expectAsync1 ((state) => state.item4, count: 8 + 1 ),
1353
+ // 8 action causes state changed
1354
+ expectAsync1 ((state) => state.item5, count: 8 + 1 ),
1355
+ // 8 action causes state changed
1356
+ expectAsync1 ((state) => state.item6, count: 8 + 1 ),
1357
+ // 8 action causes state changed
1358
+ ],
1359
+ [null , null , null , null , null , null ],
1360
+ expectAsync1 (
1361
+ (subStates) => Tuple6 (
1362
+ subStates[0 ] as int ,
1363
+ subStates[1 ] as double ,
1364
+ subStates[2 ] as String ,
1365
+ subStates[3 ] as bool ,
1366
+ subStates[4 ] as BuiltList <String >,
1367
+ subStates[5 ] as BuiltMap <String , int >,
1368
+ ),
1369
+ count: 6 + 1 , // inc. calling to produce seed value
1370
+ ),
1371
+ );
1372
+
1373
+ expect (
1374
+ tuple$.value,
1375
+ Tuple6 (0 , 1.0 , '' , true , < String > [].build (),
1376
+ < String , int > {}.build ()));
1377
+ final future = expectLater (
1378
+ tuple$,
1379
+ emitsInOrder (< Object > [
1380
+ Tuple6 (1 , 1.0 , '' , true , < String > [].build (),
1381
+ < String , int > {}.build ()),
1382
+ Tuple6 (1 , 3.0 , '' , true , < String > [].build (),
1383
+ < String , int > {}.build ()),
1384
+ Tuple6 (1 , 3.0 , '4' , true , < String > [].build (),
1385
+ < String , int > {}.build ()),
1386
+ Tuple6 (1 , 3.0 , '4' , false , < String > [].build (),
1387
+ < String , int > {}.build ()),
1388
+ Tuple6 (1 , 3.0 , '4' , false , < String > ['7' ].build (),
1389
+ < String , int > {}.build ()),
1390
+ Tuple6 (1 , 3.0 , '4' , false , < String > ['7' ].build (),
1391
+ < String , int > {'@' : 8 }.build ()),
1392
+ emitsDone,
1393
+ ]),
1394
+ );
1395
+
1396
+ for (var i = 0 ; i <= 9 ; i++ ) {
1397
+ i.dispatchTo (store);
1398
+ }
1399
+ await pumpEventQueue (times: 100 );
1400
+ await store.dispose ();
1401
+ await future;
1402
+ });
1187
1403
});
1188
1404
});
1189
1405
});
0 commit comments