Course of Raku / Functional, concurrent, reactive, and web programming / Reactive programming

react and whenever

Tapping a single supply is fine, but real reactive programs often watch several streams at once and react to whichever produces a value next. Raku has dedicated syntax for this: the react block, with one or more whenever blocks inside it.

A react block sets up the reactions and then waits, running each whenever body as its supply emits — until all the supplies are done. This section shows how the two work together.

Topics in this section

Practice

Complete the 3 quizzes that cover the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. Upper-case with react
  2. Sort into two arrays
  3. Two whenevers

Course navigation

Solution: Sum a live feed   |   The react block