txt: ## supplier.md
  class Supplier
  
  Live Supply factory
  
  ```raku
  class Supplier { }
  ```
  
  This is a factory for *live* [`Supply`](/type/Supply) objects, which provides the mechanism for emitting new values onto the supplies:
  
  ```raku
  my $supplier = Supplier.new;
  my $supply_1 = $supplier.Supply;
  $supply_1.tap(-> $v { say "One $v" });
  my $supply_2 = $supplier.Supply;
  $supply_2.tap(-> $v { say "Two $v" });
  $supplier.emit(42);
  ```
  
  Will output:
  
  ｢text｣ without highlighting
  
  ```
  
  
  ```
  
  One 42
  Two 42
  
  
  ```
  
  
  ```
  
  *on demand* supplies are created by the factory methods of the [`Supply`](/type/Supply) class or by the `supply` keyword. A mixture of a live and on-demand [`Supply`](/type/Supply) can be created with a [`Supplier::Preserving`](/type/Supplier/Preserving).
  
  # [Methods](#class_Supplier "go to top of document")[§](#Methods "direct link")
  
  ## [method new](#class_Supplier "go to top of document")[§](#method_new "direct link")
  
  ```raku
  method new()
  ```
  
  The `Supplier` constructor.
  
  ## [method Supply](#class_Supplier "go to top of document")[§](#method_Supply "direct link")
  
  ```raku
  method Supply(Supplier:D: --> Supply)
  ```
  
  This creates a new [`Supply`](/type/Supply) object to which any values which are emitted on this supplier are passed. This is the factory for all `live` supplies.
  
  ## [method emit](#class_Supplier "go to top of document")[§](#method_emit "direct link")
  
  ```raku
  method emit(Supplier:D: Mu \value)
  ```
  
  Sends the given value to all of the taps on all of the supplies created by [`Supply`](/type/Supply) on this `Supplier`.
  
  ## [method done](#class_Supplier "go to top of document")[§](#method_done "direct link")
  
  ```raku
  method done(Supplier:D:)
  ```
  
  Calls the `done` callback on all the taps that have one.
  
  ```raku
  my $supplier = Supplier.new;
  my $supply   = $supplier.Supply;
  $supply.tap(-> $v { say $v }, done => { say "no more answers" });
  $supplier.emit(42);
  $supplier.done;
  ```
  
  Will output:
  
  ｢text｣ without highlighting
  
  ```
  
  
  ```
  
  42
  no more answers
  
  
  ```
  
  
  ```
  
  ## [method quit](#class_Supplier "go to top of document")[§](#method_quit "direct link")
  
  ```raku
  multi method quit(Supplier:D: Exception $ex)
  multi method quit(Supplier:D: Str() $message)
  ```
  
  Calls the `quit` callback on all the taps that have one, passing the exception to them. If called with a [`Str`](/type/Str) the exception will be an [`X::AdHoc`](/type/X/AdHoc) with the supplied message.
  
  This is meant for shutting down a supply with an error.
  
  # [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")
  
  Type relations for `Supplier`
  
  
  
  raku-type-graph
  
  
  
  Supplier
  Supplier
  
  
  Any
  Any
  
  
  Supplier->Any
  
  
  
  Mu
  Mu
  
  
  Any->Mu
  
  
  
  Supplier::Preserving
  Supplier::Preserving
  
  
  Supplier::Preserving->Supplier
  
  [Expand chart above](/assets/typegraphs/Supplier.svg)
  