Two Mechanisms
| Events | Hooks | |
|---|---|---|
| Purpose | Notify | Extend |
| Return values | No | Yes |
| Use case | ”Something happened" | "Add your thing to my thing” |
Events (Pub/Sub)
Emitting
Listening
One-Shot Listening
Unsubscribing
Full Example
Hooks (Extension Points)
Registering
Using
Removing
Full Example
Reacting to Lifecycle Events
After All Plugins Load
Useboard:allPluginsLoaded when your plugin depends on other plugins being ready:
Listening to Other Plugins’ Events
Best Practices
Don't import other plugins
Don't import other plugins
Always use events or hooks — never
import('./other-plugin.js').Use namespaced event names
Use namespaced event names
my-plugin:action not action.Clean up listeners
Clean up listeners
Remove event listeners and hooks in your
teardown() function:Use `once` for one-time setup
Use `once` for one-time setup