Server/WebView Events

Client Enviroment

Decorators

Name Arguments Description
@OnServer() name?: string Listens to server events.
@OnceServer() name?: string Listens to server events once.
@OnWebView() id: string | number, name?: string Listens to WebView events.
@OnceWebView() id: string | number, name?: string Listens to WebView events once.

@OnServer()

The OnServer decorator is used to listen to server events.

@Controller()
export class DeliciousMangoController {
    @Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;

    @OnServer('eat')
    public onEat() {
        this.loggerService.log('Server said to the client that it ate a delicious mango!');
    }
}
ts

@OnceServer()

The OnceServer decorator is used to listen to server events once.

@Controller()
export class DeliciousMangoController {
    @Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;

    @OnceServer('eat')
    public onEat() {
        this.loggerService.log('Server said to the client that it ate a delicious mango!');
    }
}
ts

@OnWebView()

The OnWebView decorator is used to listen to WebView events.

@Controller()
export class DeliciousMangoController {
    @Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;

    @OnWebView('my_webview_id', 'eat')
    public onEat() {
        this.loggerService.log('WebView said to the client that it ate a delicious mango!');
    }
}
ts

@OnceWebView()

The OnceWebView decorator is used to listen to WebView events once.

@Controller()
export class DeliciousMangoController {
    @Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;

    @OnceWebView('my_webview_id', 'eat')
    public onEat() {
        this.loggerService.log('WebView said to the client that it ate a delicious mango!');
    }
}
ts
Last update at: 2024/06/18 19:03:08