Binding a function to event
Listening to events become simple with decorators
Overview
SugoiJS provide single line binding solution for binding a class method to socket event
Bind socket events
Listening to socket events become simple with @SocketOn decorator
event
- The event name
namespace
- The related namespace which the socket should be related to.
middlewares
- 0...n arguments of middleware functions which should occur before the event callback function.
Another signature of this decorator is:
This decorator registers the function as a callback for an event. In case middlewares functions were passed, those methods will occur right before the callback function.
Example
You can bind one function to multiple events by use multiple @SocketOn
decorators.
Bind Server events
Listening to Socket events become simple with @SocketServerOn decorator
event
- The event name
namespace
- The related namespace which the socket should be related to.
middlewares
- 0...n arguments of middleware functions which should occur before the event callback function.
Another signature of this decorator is:
This decorator registers the function as a callback for an event. In case middlewares functions were passed, those methods will occur right before the callback function.
Example
You can bind one function to multiple events by use multiple @SocketServerOn
decorators.
Last updated