Live supplies generate data regardless of the number of taps. Unlike on-demand supplies, if there are no taps open, emitted data is still generated and it simply disappears. As soon as the tap is open, it starts receiving data from that moment; all the history is lost.
To create a live supplier, call a constructor of the Supplier class. A tap must be connected to the supply, returned by the Supply factory method. This is all shown in the following example:
my $supplier = Supplier.new;
$supplier.Supply.tap({
say $_;
});
$supplier.emit($_) for 'a'..'e';
You may be a bit confused by the presence of both the Supply and Supplier classes. The Supplier class is a factory to generate live supplies.
Let us see how live supply streams data and what happens when no taps are open. In the program below, a live supply generates data in a separate thread created...