Event - WorkAdventure Documentation
Event - WorkAdventure Documentation
Api Reference See the events documentation for an introduction to the "events" concept.
Camera
data (type: unknown ): the payload of the event. Can be any JSON-serializable value (including objects, arrays, strings, numbers,
Player
booleans, undefined, etc.).
Players
The dispatchEvent method returns a promise that will be resolved when the event has successfully reached the server.
Room
Start
WA.event.broadcast("my-event", "my payload");
State
UI
Deprecated Functions
Listening to events
Extended utility functions
Events can be listened to using WA.event.on .
Scripting Internals
Using Typescript
import type { Observable } from "rxjs";
Map Storage API
type ScriptingEvent = {
Room API name: string;
data: unknown;
senderId: number | undefined;
}
on returns an RxJS Observable. You can use the subscribe method to listen to events. The subscribe method takes a callback
function that will be called each time an event is received. The callback function takes a single argument: the event object of type
ScriptingEvent .
senderId (type: number ): the ID of the player that sent the event (or undefined if the event was sent by the system)
The subscribe method returns a Subscription object. You can use the unsubscribe method of this object to stop listening to
events.
// ...
subscription.unsubscribe();
Previous Next
« Controls Map Editor API »