Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

defineEvent

defineEvent(name): EventHandle<NoRecord, Reliable, Entity>

Makes an event under name, which the log, the dump, the devtools and a room’s stream know it by: defineEvent("damaged", { amount: 0, at: new Vector3() }). The record is its fields’ defaults, or a function that makes them; with none, or one with no field, the event carries no record. Each emit is one event, delivered once to each system and once to each view that listens, in the order emitted. Called once, at module scope, in a module the room and the page both import.

Parameter Type
name string

EventHandle<NoRecord, Reliable, Entity>

defineEvent<Delivery, Scope>(name, schema, options): EventHandle<NoRecord, Delivery, Scope>

Makes an event under name, which the log, the dump, the devtools and a room’s stream know it by: defineEvent("damaged", { amount: 0, at: new Vector3() }). The record is its fields’ defaults, or a function that makes them; with none, or one with no field, the event carries no record. Each emit is one event, delivered once to each system and once to each view that listens, in the order emitted. Called once, at module scope, in a module the room and the page both import.

Type Parameter Default type
Delivery extends EventDelivery Reliable
Scope extends EventScope Entity
Parameter Type
name string
schema undefined
options Pick<EventOptions<NoRecord, Delivery, Scope>, "delivery" | "scope">

EventHandle<NoRecord, Delivery, Scope>

defineEvent<Schema, Delivery, Scope>(name, schema, …options): EventHandle<RecordOf<Schema>, Delivery, Scope>

Makes an event under name, which the log, the dump, the devtools and a room’s stream know it by: defineEvent("damaged", { amount: 0, at: new Vector3() }). The record is its fields’ defaults, or a function that makes them; with none, or one with no field, the event carries no record. Each emit is one event, delivered once to each system and once to each view that listens, in the order emitted. Called once, at module scope, in a module the room and the page both import.

Type Parameter Default type
Schema extends object -
Delivery extends EventDelivery Reliable
Scope extends EventScope Entity
Parameter Type
name string
schema Schema
…options RequiredWhereEntities<RecordOf<Schema>, EventOptions<RecordOf<Schema>, Delivery, Scope>>

EventHandle<RecordOf<Schema>, Delivery, Scope>