-
Notifications
You must be signed in to change notification settings - Fork 1
Events
Lightsheet uses an event system for communication between the core (Sheet.ts
) and UI (render.ts
) components. The protocol defines UI events, prefixed with UI_
, and core events, prefixed with CORE_
.
UI events are emitted by render.ts
when data is modified in the sheet view, and core events are emitted when a change happens that should be reflected in the UI.
The event system can be accessed via Lightsheet.events
. The events API allows for emitting events using Events.emit
and subscribing to events via Events.on(EventType, ListenerFunction, EventState)
. A ListenerFunction
is a function with a signature of (event: Event) => void
. EventState
determines when the listener function is invoked, and by default is assigned to EventState.POST_EVENT
.
If EventState.PRE_EVENT
is used instead, the listener function will be invoked before POST_EVENT
listeners. This allows for modifying event contents or canceling events by modifying the canceled
flag of the event object.