Live Supply factory
This is a factory for live Supply objects, which provides the mechanism for emitting new values onto the supplies:
my = Supplier.new;my = .Supply;.tap(-> );my = .Supply;.tap(-> );.emit(42);
Will output:
One 42Two 42
on demand supplies are created by the factory methods of the Supply class or by the supply
keyword. A mixture of a live and on-demand Supply
can be created with a Supplier::Preserving.
method new()
The Supplier
constructor.
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.
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
.
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:
42no more answers
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.