-
-
Save jnthn/d91b387c56d68f48d8a5233a23ddca21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub share($p, $s) { | |
supply { | |
whenever $p { | |
whenever $s { | |
.emit; | |
} | |
} | |
}.share | |
} | |
my $s = supply { | |
"called".say; | |
emit 1; | |
die "I am die"; | |
}; | |
$s = share(my $p = Promise.new, $s); | |
$s.tap( -> $v { say "tap {$v}"; }); | |
react { | |
whenever $s { say $_; }; | |
$p.keep(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment