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
Articles by others on the same topic
There are currently no matching articles.