Top
You are looking at an outdated 7.2.0 version of this document. Switch to the 7.14.3 version to see the up to date information.

class anychart.Base Improve this Doc

Extends: goog.events.EventTarget

Class implementins all the work with consistency states. invalidate() and markConsistent() are used to change states. isConsistent() and hasInvalidationState() are used to check states.

Methods Overview

Miscellaneous
listen()Adds an event listener to an implementing object.
listenOnce()Adds an event listener to an implementing object.
removeAllListeners()Removes all listeners from an object. You can also optionally remove listeners of some particular type.
unlisten()Removes a listener added using listen() or listenOnce() methods.
unlistenByKey()Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Methods Description

listen

Adds an event listener to an implementing object.
The listener can be added to an object once, and if it is added one more time, its key will be returned.
Note Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.

Params:

Name Type Description
type string | !goog.events.EventId.<EVENTOBJ> The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope SCOPE Object in whose scope to call the listener.

Returns:

goog.events.ListenableKey - Unique key for the listener.

Try it:

listenOnce

Adds an event listener to an implementing object.
After the event is called, its handler will be deleted.
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).

Params:

Name Type Description
type string | !goog.events.EventId.<EVENTOBJ> The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope SCOPE Object in whose scope to call the listener.

Returns:

goog.events.ListenableKey - Unique key for the listener.

Try it:

removeAllListeners

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

Name Type Description
type string Type of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

Try it:

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

Name Type Description
type string | !goog.events.EventId.<EVENTOBJ> The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope SCOPE Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

Try it:

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

Name Type Description
key goog.events.ListenableKey The key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

Try it: