Packages > @fluidframework/tree > Listenable

Listenable Interface

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

Signature

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

Type Parameters

Parameter Constraint Description
TListeners object

Methods

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

Method Details

on

Register an event listener.

Signature

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

Remarks

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.

Parameters

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

Returns

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