txt: ## react.md
  react
  
  Combined from primary sources listed below.
  
  # [In Concurrency](#___top "go to top of document")[§](#(Concurrency)_react_react "direct link")
  
  See primary documentation
  [in context](/language/concurrency#react)
  for **react**.
  
  The `react` keyword introduces a block of code containing one or more `whenever` keywords to watch asynchronous events. The main difference between a supply block and a react block is that the code in a react block runs where it appears in the code flow, whereas a supply block has to be tapped before it does anything.
  
  Another difference is that a supply block can be used without the `whenever` keyword, but a react block requires at least one `whenever` to be of any real use.
  
  ```raku
  react {
      whenever Supply.interval(2) -> $v {
          say $v;
          done() if $v == 4;
      }
  }
  ```
  
  Here the `whenever` keyword uses [`.act`](/type/Supply#method_act) to create a tap on the [`Supply`](/type/Supply) from the provided block. The `react` block is exited when `done()` is called in one of the taps. Using `last` to exit the block would produce an error indicating that it's not really a loop construct.
  
  An `on-demand` [`Supply`](/type/Supply) can also be created from a list of values that will be emitted in turn, thus the first `on-demand` example could be written as:
  
  ```raku
  react {
      whenever Supply.from-list(1..10) -> $v {
          say $v;
      }
  }
  ```
  