Improves type safety of the event system by requiring explicit types in event dispatchers and listeners (it was pretty easy to mess up with all the polymorphic types before).
Allows buffer-specific event-listeners and event dispatch which is pretty cool.
Makes 'returned' values from event dispatching easy and type-safe (I don't have example yet though sorry š )
Downsides:
Extensions must now create their own dispatch and register functions to avoid ambiguous type errors; this is a feature in disguise because now the use of these functions will throw errors if used with the wrong types (whereas the old dispatchEvent didn't). I've provided dispatchEvent and addListener which essentially automate the process; you just need to specify your type signature to use these.
Since this is now implemented as part of the extension system it prevents us from tracking every dispatched event through interpreting the DispatchEvent free monad; this may reduce flexibility when we start looking at undo trees etc. in the future. I think we could build it back into dispatchEvent in the future if we like.
Here's an example of how an extension (a simple clipboard ext) would set up its listeners/dispatchers by using more concrete types:
I recently realized that with a bit of cleverness we could implement the event system using only the extension system. Pros/Cons listed below.
This would nullify the need for https://github.com/ChrisPenner/rasa/pull/41
Benefits:
Downsides:
dispatch
andregister
functions to avoidambiguous type
errors; this is a feature in disguise because now the use of these functions will throw errors if used with the wrong types (whereas the old dispatchEvent didn't). I've provideddispatchEvent
andaddListener
which essentially automate the process; you just need to specify your type signature to use these.DispatchEvent
free monad; this may reduce flexibility when we start looking at undo trees etc. in the future. I think we could build it back intodispatchEvent
in the future if we like.Here's an example of how an extension (a simple clipboard ext) would set up its listeners/dispatchers by using more concrete types: