Create a publish/subscribe event bus.
Applications usually receive the singleton instance by
injecting $eventBus instead of constructing
this class directly.
Handler invoked when a subscriber throws.
Dispose the instance, removing all topics and listeners.
Get the number of subscribers for a topic.
This is the public diagnostic surface for
$eventBus. It reports active registered
listeners only; topic listings, leak reports, and
reactive diagnostics are intentionally not exposed.
Topic name to inspect.
The number of currently registered listeners.
Checks if instance has been disposed.
True if disposed.
Publish a value to a topic asynchronously.
Listeners are invoked in the order they were added until
delivery finishes or
$exceptionHandler terminates the
publication. Delivery is scheduled with
queueMicrotask. Scope-owned listeners are
skipped if their scope is destroyed before the queued
delivery runs.
The topic to publish.
Arguments to pass to listeners.
True if any listeners exist for this topic.
Reset the bus to its initial state without disposing it.
All topics and listeners are removed, and the instance can be reused.
Replace the runtime delivery policy used by future publications.
The default policy delivers every active listener. Configured policies can drop deliveries for specific topics, scopes, or application metadata.
Optionalpolicy:
EventDeliveryPolicy
Subscribe a function to a topic.
The returned function removes only this listener
registration. When context is provided, it
becomes the listener this binding. When
context is an AngularTS scope proxy, the
scope also owns the listener lifecycle: destroying the
scope removes the listener and prevents queued delivery
from reaching the destroyed scope.
The topic to subscribe to.
The callback function to invoke when published.
A function that unsubscribes this listener.
Subscribe a function to a topic.
The returned function removes only this listener
registration. When context is provided, it
becomes the listener this binding. When
context is an AngularTS scope proxy, the
scope also owns the listener lifecycle: destroying the
scope removes the listener and prevents queued delivery
from reaching the destroyed scope.
The topic to subscribe to.
The callback function to invoke when published.
A function that unsubscribes this listener.
Subscribe a function to a topic only once.
Listener is removed before the first invocation. When
context is provided, it becomes the
listener this binding. When
context is an AngularTS scope proxy, scope
destruction before first delivery removes the one-time
listener.
The topic to subscribe to.
The callback function.
A function that unsubscribes this listener.
Subscribe a function to a topic only once.
Listener is removed before the first invocation. When
context is provided, it becomes the
listener this binding. When
context is an AngularTS scope proxy, scope
destruction before first delivery removes the one-time
listener.
The topic to subscribe to.
The callback function.
A function that unsubscribes this listener.
Unsubscribe a specific function from a topic. Matches by function reference and optional context.
The topic to unsubscribe from.
The listener function.
True if the listener was found and removed.
Unsubscribe a specific function from a topic. Matches by function reference and optional context.
The topic to unsubscribe from.
The listener function.
True if the listener was found and removed.
Application-wide asynchronous publish/subscribe utility.
EventBuspowers$eventBusfor cross-boundary domain events, browser callbacks, worker messages, realtime messages, and non-Angular integrations. It is intentionally not a state store and should not replace scope events for parent/child scope-tree communication.