-
Notifications
You must be signed in to change notification settings - Fork 0
EventListener
dannysmc95 edited this page Feb 24, 2022
·
1 revision
Event listeners are essentially application hooks, there are currently 6 available events:
| Name | Description |
|---|---|
BEFORE_INIT |
Called before the application is initialized. |
AFTER_INIT |
Called after the application is initialized. |
BEFORE_START |
Called before the application is started. |
AFTER_START |
Called after the application is started. |
BEFORE_STOP |
Called before the application is stopped. |
AFTER_STOP |
Called after the application is stopped. |
You can hook into these by creating a listener, example below:
import { Event } from '@symbux/turbo';
@Event.Listener()
export default class ExampleListener {
@Event.On.BeforeInit()
public async beforeInit(): Promise<void> {
console.log('BEFORE INIT CALLED');
}
@Event.On.AfterInit()
public async afterInit(): Promise<void> {
console.log('AFTER INIT CALLED');
}
@Event.On.BeforeStart()
public async beforeStart(): Promise<void> {
console.log('BEFORE START CALLED');
}
@Event.On.AfterStart()
public async afterStart(): Promise<void> {
console.log('AFTER START CALLED');
}
@Event.On.BeforeStop()
public async beforeStop(): Promise<void> {
console.log('BEFORE STOP CALLED');
}
@Event.On.AfterStop()
public async afterStop(): Promise<void> {
console.log('AFTER STOP CALLED ');
}
}You can create many listeners, and they will be called in the order they were registered by the autowire module, which is usually based on order in the file system structure.
- Controllers
- Middleware
- Autowire
- Plugins
- Tasks
- Fibres
- Authentication
- Registry
- Services
- Dependecy Injection
- Translations (i18n)
- Safe Quit
- Exception Handling
- Event Listener
- Custom Logger
- HTTP Plugin - Built-In
- WS Plugin - Built-In
- Discord Plugin - External
- Vite Plugin - External
- Inspect Plugin - External
- CLI Plugin - External
- Got an issue? Join our Discord
- Need your own plugin? Contact Me
- Have an idea? Let's Discuss
- Want to support me? Buy me a coffee