@OnEvent - event handling
Handling in-instance events with channel based
Overview
SugoiJS provides a way to emit and handle events based on channels.
Usage
Listening to event
overview
Using the @OnEvent
decorator we can bind the decorated method with the event.
OnEvent(event: string, once?: boolean, channel?: string)
event - Event name to bind to
once - Should listen to the event once (default: false)
channel - The channel name of the event tunnel (default: 'DEFAULT')
Example
Emit event
overview
Using the @sugoi/server EventEmitter
class we can emit data based on channels
const emitter = new EventEmitter(channelName)
channel - The channel name of the event tunnel (default: 'DEFAULT')
Example
Full example
Last updated