Skip to content

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.

Features

Plugins

Future Plans

Resources

Clone this wiki locally