AngularTS
    Preparing search index...

    Class PubSub

    Index

    Constructors

    Properties

    $exceptionHandler: ExceptionHandler

    Methods

    • Dispose the instance, removing all topics and listeners.

      Returns void

    • Get the number of subscribers for a topic.

      Parameters

      • topic: string

      Returns number

    • Checks if instance has been disposed.

      Returns boolean

      True if disposed.

    • Publish a value to a topic asynchronously. All listeners are invoked in the order they were added.

      Parameters

      • topic: string

        The topic to publish.

      • ...args: any[]

        Arguments to pass to listeners.

      Returns boolean

      True if any listeners exist for this topic.

    • Set instance to initial state

      Returns void

    • Subscribe a function to a topic.

      Parameters

      • topic: string

        The topic to subscribe to.

      • fn: Function

        The callback function to invoke when published.

      • Optionalcontext: any = undefined

        Optional this context for the callback.

      Returns () => boolean

      A function that unsubscribes this listener.

    • Subscribe a function to a topic only once. Listener is removed before the first invocation.

      Parameters

      • topic: string

        The topic to subscribe to.

      • fn: Function

        The callback function.

      • Optionalcontext: any = undefined

        Optional this context for the callback.

      Returns () => boolean

      A function that unsubscribes this listener.

    • Unsubscribe a specific function from a topic. Matches by function reference and optional context.

      Parameters

      • topic: string

        The topic to unsubscribe from.

      • fn: Function

        The listener function.

      • Optionalcontext: any = undefined

        Optional this context.

      Returns boolean

      True if the listener was found and removed.