In Control flow§
See primary documentation in context for supply/emit.
The keyword supply
creates a Supply object which is an on-demand supply that you can tap. It pairs with emit
, which can be used anywhere from within supply
prefixed code.
Using the emit method
or the emit routine
passes the invocant to the enclosing supply:
my $supply = supply { .emit for "foo", 42, .5; } $supply.tap: { say "received {.^name} ($_)"; } # OUTPUT: # received Str (foo) # received Int (42) # received Rat (0.5)