class Supplier::Preserving
Cached live Supply factory
1 | Methods |
1.1 | method new |
2 | Type Graph |
3 | Routines supplied by class Supplier |
3.1 | (Supplier) method new |
3.2 | (Supplier) method Supply |
3.3 | (Supplier) method emit |
3.4 | (Supplier) method done |
3.5 | (Supplier) method quit |
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 ^3sleep 2;reactsay „also done after s“
Will output:
done after 0.0638467s012also done after 4.0534119s
Methods
method new
method new()
The Supplier
constructor.
Type Graph
Routines 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:
42no 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.