@microsoft/fast-element > SubscriberSet

SubscriberSet class

An implementation of Notifier that efficiently keeps track of subscribers interested in a specific change notification on an observable subject.

Signature:

export declare class SubscriberSet implements Notifier 

Implements: Notifier

Remarks

This set is optimized for the most common scenario of 1 or 2 subscribers. With this in mind, it can store a subscriber in an internal field, allowing it to avoid Array#push operations. If the set ever exceeds two subscribers, it upgrades to an array automatically.

Constructors

Constructor

Modifiers

Description

(constructor)(subject, initialSubscriber)

Creates an instance of SubscriberSet for the specified subject.

Properties

Property

Modifiers

Type

Description

subject

readonly

any

The object that subscribers will receive notifications for.

Methods

Method

Modifiers

Description

has(subscriber)

Checks whether the provided subscriber has been added to this set.

notify(args)

Notifies all subscribers.

subscribe(subscriber)

Subscribes to notification of changes in an object's state.

unsubscribe(subscriber)

Unsubscribes from notification of changes in an object's state.