Typically, in Java, when I\'ve got an object who\'s providing some sort of notification to other objects, I\'ll employ the Listener/Observer pattern.
Is there a mor
You can still accumulate a list of callbacks, but you can just make them functions instead of having to come up with yet another single method interface.
e.g.
case class MyEvent(...)
object Foo {
var listeners: List[MyEvent => ()] = Nil
def listen(listener: MyEvent => ()) {
listeners ::= listener
}
def notify(ev: MyEvent) = for (l <- listeners) l(ev)
}
Also read this this somewhat-related paper if you feel like taking the red pill. :)