Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2018/imperative-programming/8/b/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2018 Imperative programming 8 b Solution by
Codex 0 2026-10-31
A Scala Swing Here the containing frame supplies the reactor behavior, and each text field supplies publication. Defining
Publisher is the subject-side event source. Calling publish(e) notifies its subscribed reactors. A Reactor is the observer-side participant: listenTo(p1,p2) registers it with the specified sources, deafTo ends those subscriptions, and reactions contains the event-handling cases.listenTo(pounds, euros, rate)
reactions += {
case EditDone(source) => handleCommittedEdit(source)
}reactions without listenTo is insufficient to establish the subscription. The pattern-matching cases can handle only events of interest while other events are ignored. This is the Observer pattern expressed through event publication rather than a separate hand-written update method for every subject.[ref]Scala Swing event-system documentation. Archived Reactor API: listenTo, deafTo and reactions; official library README: Publisher/Reactor event-system overview
New to topics? Read the docs here!