#!/usr/bin/env perl6 sub count-down(Int $n is copy, Supply $ns --> Supply) { supply { whenever $ns { say "INNER GET ", $_; $n = $_; } while $n >= 0 { emit $n; say "123"; $n -= 1; } } } sub MAIN() { my $supplier = Supplier.new; react { whenever &count-down(5, $supplier.Supply) { say "OUT GET ", $_; if $_ == 5 { $supplier.emit(3); } } } }