Given a supplier in $s
, this allows a consumer to know if $signal
has been tapped by setting
the appropriate entry in %sigs
sub create-signal-supply (%sigs, $signal, $s) {
my $supply = $s.Supply;
$supply.^can('tap')[0].wrap: -> |c {
%sigs{$signal} = True;
nextsame;
});
$supply;
}
This should work, however getting the following...
Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block at /home/cbwood/Projects/p6-GLib/lib/GLib/Raw/Subs.pm6 (GLib::Raw::Subs) line 233
in block at /home/cbwood/Projects/p6-GLib/lib/GLib/Raw/Subs.pm6 (GLib::Raw::Subs) line 233
in block at /home/cbwood/Projects/p6-GLib/lib/GLib/Raw/Subs.pm6 (GLib::Raw::Subs) line 233
in submethod BUILD at /home/cbwood/Projects/p6-GtkPlus/lib/GTK/Application.pm6 (GTK::Application) line 67
in method new at /home/cbwood/Projects/p6-GtkPlus/lib/GTK/Application.pm6 (GTK::Application) line 152
in block <unit> at t/0010-widget.t line 11
Hah! This is the fixed version!
sub create-signal-supply (%sigs, $signal, $s) {
my $supply = $s.Supply;
$supply.^lookup('tap').wrap: my method (|c) {
%sigs{$signal} = True;
nextsame;
};
$supply;
}