Class HasEventHandling
java.lang.Object
io.deephaven.web.client.api.event.HasEventHandling
- Direct Known Subclasses:
AbstractTableSubscription,CoreClient,HasLifecycle,IdeSession,JsChart,JsWidget,QueryConnectable,ResponseStreamWrapper
Base class providing an event listener API for Deephaven JS client objects.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringInternal event name used by some implementations to indicate that the underlying object has been released. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> RemoverFnaddEventListener(String name, EventFn<T> callback) Listen for events on this object.voidaddEventListenerOneShot(HasEventHandling.EventPair<?>... pairs) <T> voidaddEventListenerOneShot(String name, EventFn<T> callback) voidfailureHandled(String failure) <T> voidfireCriticalEvent(String type) Fires a critical event with no detail.<T> voidfireCriticalEvent(String type, T detail) Fires a critical event with the given detail.<T> voidFires an event instance.voidFires an event with no detail.<T> voidFires an event with the given detail payload.booleanhasListener(String name, EventFn<?> fn) Checks whether a specific event listener is registered for the given event name.booleanhasListeners(String name) Checks whether any event listeners are registered for the given event name.booleanChecks whether events are currently suppressed.protected String<T> elemental2.promise.Promise<Event<T>> Returns a promise that resolves the next time the named event occurs, with the value of the event's detail.<T> booleanremoveEventListener(String name, EventFn<T> callback) Removes an event listener added to this table.voidSuppresses delivery of fired events to listeners.voidRe-enables delivery of fired events to listeners.
-
Field Details
-
INTERNAL_EVENT_RELEASED
Internal event name used by some implementations to indicate that the underlying object has been released.- See Also:
-
-
Constructor Details
-
HasEventHandling
public HasEventHandling()
-
-
Method Details
-
logPrefix
-
addEventListener
Listen for events on this object.- Type Parameters:
T- The type of the data that the event will provide.- Parameters:
name- The name of the event to listen for.callback- A function to call when the event occurs.- Returns:
- Returns a cleanup function.
-
addEventListenerOneShot
-
addEventListenerOneShot
-
nextEvent
@JsMethod public <T> elemental2.promise.Promise<Event<T>> nextEvent(String eventName, @JsOptional @JsNullable Double timeoutInMillis) Returns a promise that resolves the next time the named event occurs, with the value of the event's detail. If a timeout is specified and occurs before the event takes place, the promise will reject, otherwise waits indefinitely.- Type Parameters:
T- The type of the event detail.- Parameters:
eventName- The event name.timeoutInMillis- Optional timeout in milliseconds.- Returns:
- A promise that resolves with the next matching event.
-
hasListeners
Checks whether any event listeners are registered for the given event name.- Parameters:
name- The event name.- Returns:
trueif there is at least one listener registered forname;falseotherwise.
-
hasListener
Checks whether a specific event listener is registered for the given event name.- Parameters:
name- The event name.fn- The event listener function.- Returns:
- True if
fnis currently registered forname.
-
removeEventListener
Removes an event listener added to this table.- Type Parameters:
T-- Parameters:
name-callback-- Returns:
-
fireEvent
Fires an event with no detail.- Parameters:
type- The event name.
-
fireEvent
Fires an event with the given detail payload.- Parameters:
type- The event name.detail- The event detail.
-
fireEvent
Fires an event instance.- Parameters:
e- The event to fire.
-
fireCriticalEvent
Fires a critical event with no detail.If no listeners are registered, a message is logged to the console.
- Parameters:
type- The event type.
-
fireCriticalEvent
Fires a critical event with the given detail.If no listeners are registered, a message is logged to the console.
- Parameters:
type- The event type.detail- The event detail.
-
failureHandled
-
suppressEvents
public void suppressEvents()Suppresses delivery of fired events to listeners. -
unsuppressEvents
public void unsuppressEvents()Re-enables delivery of fired events to listeners. -
isSuppress
public boolean isSuppress()Checks whether events are currently suppressed.- Returns:
- True if events are suppressed.
-