class Supplier::Preserving
ErrorsCollection

class Supplier::Preserving

Cached live Supply factory

class Supplier::Preserving is Supplier { }

This is a factory for live Supply-type objects, and it provides the mechanism for emitting new values onto the supplies, whereby values are kept when no consumer has tapped into the Supply. Any tapping will consume the already stored and future values.

Starting a preserving Supply and consuming its values after it is done:

my $p = Supplier::Preserving.new;
start for ^3 {
    $p.emit($_);
    LAST {
        say done after { now - BEGIN now}s;
        $p.done;
    }
}
sleep 2;
react {
    whenever $p.Supply { $_.say}
    whenever Promise.in(2{ done }
}
say also done after { now - BEGIN now }s

Will output:

done after 0.0638467s
0
1
2
also done after 4.0534119s

Methods

method new

method new()

The Supplier constructor.