8
Is it possible to get the domain of a Partial Function in Scala?
Ex:
val f: PartialFunction[Int, Unit] = {
case 1 => println("This is 1")
case 2 => println("This is 2")
}
Is there any way to get something like:
val list = f.getDomain
which would indicate values 1 and 2?
Update: I am trying to build an notification system (event bus). The subscriber will look like this:
class SomeSubscriber extends Subscriber {
notifications {
case LoginEvent(date) => println("Login on " + date)
case LogoutEvent(date) => println("Logout on " + date)
case e: Notification[Any] => async {
println("Other notification: " + e)
ui {
println("UI in async! " + e)
}
}
}
}
In my NotiticationService (the event dispatcher) I want to access the events declared in every 'notifications' block so I can push the notifications to the subscribers. How can I do that?
Thanks in advance.