goog.Disposable | |
goog.pubsub.PubSub | goog.Disposable |
![]()
Clears the subscription list for a topic, or all topics if unspecified.
Arguments:
|
code » | ||
![]()
No description.
|
code » | ||
Returns the number of subscriptions to the given topic (or all topics if
unspecified).
Arguments:
Returns: number
Number of subscriptions to the topic.
|
code » | ||
Publishes a message to a topic. Calls functions subscribed to the topic in
the order in which they were added, passing all arguments along. If any of
the functions throws an uncaught error, publishing is aborted.
|
code » | ||
Subscribes a function to a topic. The function is invoked as a method on
the given
opt_context object, or in the global scope if no context
is specified. Subscribing the same function to the same topic multiple
times will result in multiple function invocations while publishing.
Returns a subscription key that can be used to unsubscribe the function from
the topic via #unsubscribeByKey .
|
code » | ||
Subscribes a single-use function to a topic. The function is invoked as a
method on the given
opt_context object, or in the global scope if
no context is specified, and is then unsubscribed. Returns a subscription
key that can be used to unsubscribe the function from the topic via
#unsubscribeByKey .
|
code » | ||
Unsubscribes a function from a topic. Only deletes the first match found.
Returns a Boolean indicating whether a subscription was removed.
|
code » | ||
Removes a subscription based on the key returned by
#subscribe .
No-op if no matching subscription is found. Returns a Boolean indicating
whether a subscription was removed.
|
code » |
![]()
Invokes a callback function when this object is disposed. Callbacks are
invoked in the order in which they were added.
Arguments:
|
code » | |||
![]()
Disposes of the object. If the object hasn't already been disposed of, calls
#disposeInternal . Classes that extend goog.Disposable should
override #disposeInternal in order to delete references to COM
objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void
Nothing.
|
code » | |||
![]()
Deletes or nulls out any references to COM objects, DOM nodes, or other
disposable objects. Classes that extend
goog.Disposable should
override this method.
Not reentrant. To avoid calling it twice, it must only be called from the
subclass' disposeInternal method. Everywhere else the public
dispose method must be used.
For example:
mypackage.MyClass = function() { mypackage.MyClass.base(this, 'constructor'); // Constructor logic specific to MyClass. ... }; goog.inherits(mypackage.MyClass, goog.Disposable); mypackage.MyClass.prototype.disposeInternal = function() { // Dispose logic specific to MyClass. ... // Call superclass's disposeInternal at the end of the subclass's, like // in C++, to avoid hard-to-catch issues. mypackage.MyClass.base(this, 'disposeInternal'); }; |
code » | |||
Use
#isDisposed instead.
No description.
Returns: boolean
Whether the object has been disposed of.
|
code » | |||
No description.
Returns: boolean
Whether the object has been disposed of.
|
code » | |||
![]()
Associates a disposable object with this object so that they will be disposed
together.
Arguments:
|
code » |
![]()
No description.
|
Code » | |
![]()
The next available subscription key. Internally, this is an index into the
sparse array of subscriptions.
|
Code » | |
![]()
Array of subscription keys pending removal once publishing is done.
|
Code » | |
![]()
Lock to prevent the removal of subscriptions during publishing. Incremented
at the beginning of
#publish , and decremented at the end.
|
Code » | |
![]()
Sparse array of subscriptions. Each subscription is represented by a tuple
comprising a topic identifier, a function, and an optional context object.
Each tuple occupies three consecutive positions in the array, with the topic
identifier at index n, the function at index (n + 1), the context object at
index (n + 2), the next topic at index (n + 3), etc. (This representation
minimizes the number of object allocations and has been shown to be faster
than an array of objects with three key-value pairs or three parallel arrays,
especially on IE.) Once a subscription is removed via
#unsubscribe
or #unsubscribeByKey , the three corresponding array elements are
deleted, and never reused. This means the total number of subscriptions
during the lifetime of the pubsub channel is limited by the maximum length
of a JavaScript array to (2^32 - 1) / 3 = 1,431,655,765 subscriptions, which
should suffice for most applications.
|
Code » | |
![]()
Map of topics to arrays of subscription keys.
|
Code » |
![]()
No description.
|
Code » |