File tree Expand file tree Collapse file tree 1 file changed +35
-36
lines changed Expand file tree Collapse file tree 1 file changed +35
-36
lines changed Original file line number Diff line number Diff line change @@ -424,49 +424,48 @@ C<react> block described earlier:
424
424
my $channel = Channel.new;
425
425
426
426
my $p = start {
427
- react {
428
- whenever $channel {
429
- say $_;
430
- }
431
- }
432
- }
433
-
434
- await (^10).map: -> $r {
435
- start {
436
- sleep $r;
437
- $channel.send($r);
438
- }
439
- }
440
-
441
- $channel.close;
442
- await $p;
427
+ react {
428
+ whenever $channel {
429
+ say $_;
430
+ }
431
+ }
432
+ }
433
+
434
+ await (^10).map: -> $r {
435
+ start {
436
+ sleep $r;
437
+ $channel.send($r);
438
+ }
439
+ }
440
+
441
+ $channel.close;
442
+ await $p;
443
443
444
444
It is also possible to obtain a L < Channel > from a L < Supply > using the
445
445
L < Supply method|/type/Supply#method_Channel > which returns a L < Channel >
446
446
which is fed by a C < tap > on the L < Supply > :
447
447
448
- my $supplier = Supplier.new;
449
- my $supply = $supplier.Supply;
450
- my $channel = $supply.Channel;
448
+ my $supplier = Supplier.new;
449
+ my $supply = $supplier.Supply;
450
+ my $channel = $supply.Channel;
451
451
452
+ my $p = start {
453
+ react {
454
+ whenever $channel -> $item {
455
+ say "via Channel: $item";
456
+ }
457
+ }
458
+ }
452
459
453
- my $p = start {
454
- react {
455
- whenever $channel -> $item {
456
- say "via Channel: $item";
457
- }
458
- }
459
- }
460
-
461
- await (^10).map: -> $r {
462
- start {
463
- sleep $r;
464
- $supplier.emit($r);
465
- }
466
- }
467
-
468
- $supplier.done;
469
- await $p;
460
+ await (^10).map: -> $r {
461
+ start {
462
+ sleep $r;
463
+ $supplier.emit($r);
464
+ }
465
+ }
466
+
467
+ $supplier.done;
468
+ await $p;
470
469
471
470
C < Channel > will return a different L < Channel > fed with the same data
472
471
each time it is called. This could be used, for instance, to fan-out a
You can’t perform that action at this time.
0 commit comments