Events
WebView
Listen Event Methods
Name | Description |
---|---|
on | Listens to local events. |
once | Listens to local events once. |
onPlayer | Listens to client events. |
oncePlayer | Listens to client events once. |
onServer | Listens to server events. |
onceServer | Listens to server events once. |
Mango provides a set of methods to listen to events. These methods are available in the window.mango.event
object after the mango
object is initialized in the WebView.
on
window.mango.event.on('eventName', (body: unknown) => /* ... */);
ts
once
window.mango.event.once('eventName', (body: unknown) => /* ... */);
ts
onPlayer
window.mango.event.onPlayer('eventName', (body: unknown) => /* ... */);
ts
oncePlayer
window.mango.event.oncePlayer('eventName', (body: unknown) => /* ... */);
ts
onServer
window.mango.event.onServer('eventName', (body: unknown) => /* ... */);
ts
onceServer
window.mango.event.onceServer('eventName', (body: unknown) => /* ... */);
ts
Emit Event Methods
Name | Description |
---|---|
emit | Emits local events. |
emitServer | Emit server events. |
emitPlayer | Emit client events. |
Mango provides a set of methods to emit events. These methods are available in the window.mango.event
object after the mango
object is initialized in the WebView.
const body = { color: 'yellow', ripe: true };
ts
emit
window.mango.event.emit('eventName', body);
ts
emitServer
window.mango.event.emitServer('eventName', body);
ts
emitClient
window.mango.event.emitPlayer('eventName', body);
ts