Search code examples
eventsscalasignalsdispatch

C#-like signals or AS3-like events in Scala?


How do I implement C# style signals or AS3 style events in Scala? I mean mostly observer pattern. To dispatch change events. Thanks.

Or (what's even better) are there any libraries/framework which do just that?


Solution

  • I'd suggest reading Deprecating the Observer Pattern first, for inspiration and to get a taste of where things are going.

    Then, have a look at how scala-swing uses "reactions" to see how you can do this kind of thing in a library.

    Finally, note that first-class functions make implementing the observer pattern yourself relatively easy.