Packages > @fluidframework/tree > Listenable

Listenable Interface

An object which allows the registration of listeners so that subscribers can be notified when an event happens.


/** @sealed */
export interface Listenable<TListeners extends object>

Type Parameters

Parameter Constraint Description
TListeners object


Method Return Type Description
on(eventName, listener) Off Register an event listener.

Method Details


Register an event listener.


on<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;
Type Parameters
Parameter Constraint Description
K keyof Listeners<TListeners>


Do not register the exact same listener object for the same event more than once. Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.


Parameter Type Description
eventName K the name of the event
listener TListeners[K] the handler to run when the event is fired by the emitter


a function which will deregister the listener when called. This deregistration function is idempotent and therefore may be safely called more than once with no effect.

Return type: Off