In Supplier§

See primary documentation in context for method done

method done(Supplier:D:)

Calls the done callback on all the taps that have one.

my $supplier = Supplier.new;
my $supply   = $supplier.Supply;
$supply.tap(-> $v { say $v }done => { say "no more answers" });
$supplier.emit(42);
$supplier.done;

Will output:

42
no more answers

In Independent routines§

See primary documentation in context for sub done

sub done(--> Nil)

If used outside any supply or react block, throws an exception done without supply or react. Within a Supply block, it will indicate the supply will no longer emit anything. See also documentation on method done.

my $supply = supply {
    for 1 .. 3 {
        emit($_);
    }
    done;
}
$supply.tap-> $v { say "Second : $v" }done => { say "No more" });
# OUTPUT: «Second : 1␤Second : 2␤Second : 3␤No More␤» 

The block passed to the done named argument will be run when done is called within the supply block.

As of the 2021.06 release of the Rakudo compiler, it is also possibly to supply a value with done:

sub done($value --> Nil)

The specified value will first be emitted before an argumentless done will be called.

my $supply = supply {
    for 1 .. 3 {
        emit($_);
    }
    done 42;  # same as: emit 42; done 
}
$supply.tap: -> $v { say "Val: $v" }done => { say "No more" }
# OUTPUT: OUTPUT: «Val: 1␤Val: 2␤Val: 3␤Val: 42␤No More␤»