Closed ChrisPenner closed 7 years ago
Thanks for the feedback @samcal! At the moment I'm actually second-guessing whether this is necessary; I believe it could be replace by something on the extension level of abstraction rather than in core; like this:
data Things = Things [Action Thing]
addThing :: Action Thing -> Action ()
addThing thing = do
overExt addTheThing
where addTheThing (Things ts) = Thing (thing:ts)
getThings :: Action [Action Thing]
getThings = do
Things ts <- getExt
sequence ts
This is probably simpler to understand, has more concrete types, and requires less change to the internal API with equivalent power. Modifications to this system can add the ability to 'unregister' hooks as well simply by storing the Action Thing
s in a Map instead of a list.
Unneeded as of https://github.com/ChrisPenner/rasa/pull/43
This provides the ability for extensions to actually have return values from event listeners; onEveryTrigger is now type:
When you dispatch an event you have the option to return a Monoidal result:
It calls all corresponding listeners; mconcats the results together; or returns mempty if no listeners exist.
I plan to use this to for some nifty things going forwards; for instance collecting styling information from all extensions before rendering; collecting status-bar information; rendering information, etc.
If anyone has opinions I'd love to hear them!