Page Contents

Home > @loopback/context > ContextSubscriptionManager

ContextSubscriptionManager class

Manager for context observer subscriptions

Signature:

export declare class ContextSubscriptionManager extends EventEmitter 

Extends: EventEmitter

Constructors

Constructor Modifiers Description
[(constructor)(context)](/doc/en/lb4/apidocs.context.contextsubscriptionmanager._constructor_.html) Constructs a new instance of the `ContextSubscriptionManager` class

Properties

Property Modifiers Type Description
[\_observers](/doc/en/lb4/apidocs.context.contextsubscriptionmanager._observers.html) `protected` Set<[ContextEventObserver](/doc/en/lb4/apidocs.context.contexteventobserver.html)> \| undefined A list of registered context observers. The Set will be created when the first observer is added.
[\_parentContextEventListener?](/doc/en/lb4/apidocs.context.contextsubscriptionmanager._parentcontexteventlistener.html) `protected` [ContextEventListener](/doc/en/lb4/apidocs.context.contexteventlistener.html) _(Optional)_ A listener to watch parent context events
[context](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.context.html) `protected` `readonly` [Context](/doc/en/lb4/apidocs.context.context.html)

Methods

Method Modifiers Description
[close()](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.close.html) Close the context: clear observers, stop notifications, and remove event listeners from its parent context.
[isSubscribed(observer)](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.issubscribed.html) Check if an observer is subscribed to this context
[notifyObservers(event, observers)](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.notifyobservers.html) `protected` Publish an event to the registered observers. Please note the notification is queued and performed asynchronously so that we allow fluent APIs such as `ctx.bind('key').to(...).tag(...);` and give observers the fully populated binding.
[subscribe(observer)](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.subscribe.html) Add a context event observer to the context
[unsubscribe(observer)](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.unsubscribe.html) Remove the context event observer from the context
[waitUntilPendingNotificationsDone(timeout)](/doc/en/lb4/apidocs.context.contextsubscriptionmanager.waituntilpendingnotificationsdone.html) Wait until observers are notified for all of currently pending notification events. This method is for test only to perform assertions after observers are notified for relevant events.