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.

Signature

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

Type Parameters

Parameter Constraint Description
TListeners InternalUtilityTypes.NotificationListeners<TListeners>

Methods

Method Alerts Return Type Description
off(notificationName, listener) Alpha void Deregister notification listener.
on(notificationName, listener) Alpha Off Register 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: ISessionClient, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): void;
Type Parameters
Parameter Constraint Description
K keyof 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

Parameter Type Description
notificationName K The name of the notification.
listener (sender: ISessionClient, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void The 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: ISessionClient, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): Off;
Type Parameters
Parameter Constraint Description
K keyof 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

Parameter Type Description
notificationName K the name of the notification
listener (sender: ISessionClient, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void The 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