Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub asynchronize(Supply $s) {
- #"asynchronize".say;
- supply {
- whenever Promise.kept {
- #"asynchronize whenever".say;
- whenever $s { "asynchronize whenever emit".say;.emit }
- }
- }
- }
- react {
- my $i = 0;
- my $supply1 = supply { loop { await Promise.in(3); done if $i++> 5; emit("1") } }
- my $supply2 = supply { loop { await Promise.in(1); done if $i++> 5; emit("2") } }
- whenever asynchronize $supply2 -> $x { $x.print }
- whenever asynchronize $supply1 -> $x { $x.print }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement