ChrisPenner / rasa

Extremely modular text editor built in Haskell
GNU General Public License v3.0
616 stars 42 forks source link

Implement event-system using Extension infrastructure #43

Closed ChrisPenner closed 7 years ago

ChrisPenner commented 7 years ago

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:

Here's an example of how an extension (a simple clipboard ext) would set up its listeners/dispatchers by using more concrete types:

data Copied = Copied Y.YiString

onCopy :: (Copied -> Action ()) -> Action ()
onCopy = dispatchEvent

dispatchCopy :: Copied -> Action ()
dispatchCopy = addListener