Services
Server Enviroment
Client Enviroment
Available Services
Name | Injection Token | Type | Scope |
---|---|---|---|
Event Service | EVENT_SERVICE | EventService | Singleton |
RPC Service | RPC_SERVICE | RPCService | Singleton |
Logger Service | LOGGER_SERVICE | LoggerService | Singleton |
Event Service
The event service is a service that allows you to listen to events and emit events.
@Controller()
export class FooController {
@Inject(EVENT_SERVICE) private readonly eventService: EventService;
@On('foo')
public onFoo() {
// Do something
this.eventService.emit('bar');
}
}
ts
RPC Service
The RPC service is a service that allows you to listen to RPC requests and send RPC requests.
@Controller()
export class FooController {
@Inject(RPC_SERVICE) private readonly rpcService: RPCService;
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@On('foo')
public onFoo() {
const barResult = this.rpcService.call('bar');
this.loggerService.log(barResult);
}
}
ts
Logger Service
The logger service is a service that allows you to log messages to the console.
@Controller()
export class FooController {
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@On('foo')
public onFoo() {
// Do something
this.loggerService.log('bar');
}
}
ts
On this page