Appendix B. The six plagues of event handling

We’ve identified six sources of bugs in the observer pattern. FRP banishes all of them. Here we’ll describe each problem in detail, with a short explanation of how FRP fixes it.

B.1. Plague 1: unpredictable order

Let’s say you’re developing a program for drawing diagrams, in which graphical elements can be selected or deselected. The rules are these:

  • If you click an item, it’s selected.
  • If an item is selected and you click elsewhere, it gets deselected.
  • When nothing is selected, you see a crosshair cursor.
  • When any element is selected, the cursor is an arrow.

Figure B.1 shows three steps performed with the diagram program:

1.  At first nothing is selected, and you’re ready to click the ...

Get Functional Reactive Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.