mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Use PartialFunction.applyOrElse when dispatching
This commit is contained in:
parent
22d854ed34
commit
c789722d4c
@ -2,10 +2,10 @@ package ocelot.desktop.ui.widget
|
||||
|
||||
import ocelot.desktop.ui.event.Event
|
||||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
class EventHandlers extends PartialFunction[Event, Unit] {
|
||||
private val handlers = new ListBuffer[EventHandler]
|
||||
private val handlers = ArrayBuffer.empty[EventHandler]
|
||||
|
||||
def +=(handler: EventHandler): Unit = handlers += handler
|
||||
|
||||
@ -19,9 +19,7 @@ class EventHandlers extends PartialFunction[Event, Unit] {
|
||||
return
|
||||
}
|
||||
|
||||
if (handler.isDefinedAt(event)) {
|
||||
handler(event)
|
||||
}
|
||||
handler.applyOrElse(event, (_: Event) => ())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user