[DAEMON-90] Implement hook support
It would be great to allow plugins to expose hooks that other plugins could tie into.
What is a hook?A hook is a routine that is encapsulated by an event emitter where each hook listener can interact with the hook's inputs and outputs.
How does this work?Plugins can wrap various logic in a named hook. The result is a function that when called is passed an object of params. When a hook is invoked, an event is dispatched to all listeners in series and waits until they finish before continuing.
How does this compare to the Titanium CLI's hook support?The Titanium CLI hooks allow for both event hooks and function hooks. The Appc Daemon will only allow event hooks. The Titanium CLI hooked functions allow multiple arguments. The Appc Daemon only allow a single optional argument which would be an object. The Titanium CLI allowed any data types for the arguments. The Appc Daemon only allows serializable data such as undefined, null, strings, numbers, booleans, arrays, and object literals. Object instances (those with contexts) and functions are not permitted.
- Chris Barber 2020-05-28
After analyzing the use case for a new general hook system, there really isn't a need. The Titanium appcd plugin can have it's own hook system, but that doesn't need to be a global system apart of appcd. For auth, the Titanium plugin can just call the AMPLIFY service as any other component would.