Skip to main content

NotificationListenable Interface

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

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/presence/alpha.

For more information about our API support guarantees, see here.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
export interface NotificationListenable<TListeners extends InternalUtilityTypes.NotificationListeners<TListeners>>

Type Parameters

ParameterConstraintDescription
TListenersInternalUtilityTypes.NotificationListeners<TListeners>

Methods

MethodAlertsReturn TypeDescription
off(notificationName, listener)AlphavoidDeregister notification listener.
on(notificationName, listener)AlphaOffRegister a notification listener.

Method Details

off

Deregister notification listener.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

off<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): void;
Type Parameters
ParameterConstraintDescription
Kkeyof InternalUtilityTypes.NotificationListeners<TListeners>

Remarks

If listener is not currently registered, this method will have no effect.

Listeners may also be deregistered by calling the deregistration function returned when they are registered.

Parameters

ParameterTypeDescription
notificationNameKThe name of the notification.
listener(sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => voidThe listener function to remove from the current set of notification listeners.

on

Register a notification listener.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

on<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): Off;
Type Parameters
ParameterConstraintDescription
Kkeyof InternalUtilityTypes.NotificationListeners<TListeners>

Remarks

Registering the exact same listener object for the same notification more than once will throw an error. If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.

Parameters

ParameterTypeDescription
notificationNameKthe name of the notification
listener(sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => voidThe listener function to run when the notification is fired.

Returns

A function which will deregister the listener when called. Calling the deregistration function more than once will have no effect.

Listeners may also be deregistered by passing the listener to off().

Return type: Off