Add extension events to hooks #20306
Replies: 3 comments
-
Possible workaround with Flows or Hooks: Also noted in Request Review call: |
Beta Was this translation helpful? Give feedback.
-
Events are ok for other extensions/code to be alerted about an extension being added/removed, but I think the cleanest could be adding a |
Beta Was this translation helpful? Give feedback.
-
Also related #22095 (less detailed description, but same goal). I agree to @u12206050 that
|
Beta Was this translation helpful? Give feedback.
-
Summary
Hi all,
In one of the more recent versions of Directus, the option to enable/disable extensions has been introduced.
This is great but in some cases you need to know when the extension is turned on or off.
For that reason i propose to add 2 new action events: extension.load and extension.unload.
This way you can run code to for example clean up data in Redis or files that it creates to use on the machine.
Basic Example
Motivation
Right now we have the events server.start and server.stop.
However these events are not being triggerd whenever an extension loads.
For example if the marketplace is introduced and someone installs an extension, the extension does not receive an event for the load, or when someone uninstalls the extension, there is no way of knowing that.
Detailed Design
I think the previouse explainations make sense, otherwise please let me know.
Requirements List
Must Have:
Should Have:
Could Have:
Won't Have:
Drawbacks
The drawback of this is that people could use this to start tracking the amount of (un)installs or something similar.
Alternatives
For load, you can also add your code to the code:
export default ({ action }, { env, services }) => {};
However, this will not capture the unload/disable of an extension.
Adoption Strategy
This is extra functionality so this should not break any systems.
It should be usable the same way that other action hooks can be used.
Unresolved Questions
One thing im not sure of is what parameters this should receive apart from the context object.
Beta Was this translation helpful? Give feedback.
All reactions