Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/x.p6 Secret

Created August 11, 2018 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnthn/d91b387c56d68f48d8a5233a23ddca21 to your computer and use it in GitHub Desktop.
Save jnthn/d91b387c56d68f48d8a5233a23ddca21 to your computer and use it in GitHub Desktop.
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