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 = Supplier::Preserving.new;start for ^3 sleep 2;react say „also done after s“
Will output:
done after 0.0638467s 0 1 2 also done after 4.0534119s
Methods §
method new §
method new()
The Supplier constructor.
Type Graph §
Supplier::PreservingRoutines supplied by class Supplier §
Supplier::Preserving inherits from class Supplier, which provides the following routines:
(Supplier) method new §
method new()
The Supplier constructor.
(Supplier) method Supply §
method Supply(Supplier: --> Supply)
This creates a new Supply object to which any values which are emitted on this supplier are passed. This is the factory for all live supplies.
(Supplier) method emit §
method emit(Supplier: Mu \value)
Sends the given value to all of the taps on all of the supplies created by Supply on this Supplier.
(Supplier) method done §
method done(Supplier:)
Calls the done callback on all the taps that have one.
my = Supplier.new;my = .Supply;.tap(-> , done => );.emit(42);.done;
Will output:
42 no more answers
(Supplier) method quit §
multi method quit(Supplier: Exception )multi method quit(Supplier: Str() )
Calls the quit callback on all the taps that have one, passing the exception to them. If called with a Str the exception will be an X::AdHoc with the supplied message.
This is meant for shutting down a supply with an error.