BaseClass

September 29, 2018 ยท View on GitHub


API Reference


new BaseClass()

Params Type Details

Instance method

  • addEventListener(eventName)

    Adds an event listener.

    Params Type Details
    eventName string event name

    :arrow_right: Observable<any>

  • addEventListenerOnce(eventName)

    Adds an event listener that works once.

    Params Type Details
    eventName string event name

    :arrow_right: Promise<any>

  • on(eventName)

    The same as addEventListener.

  • one(eventName)

    The same as addEventListenerOnce.

  • get(key)

    Gets a value

    Params Type Details
    key string key name

    :arrow_right: any

  • set(key, value, noNotify?)

    Sets a value with key

    Params Type Details
    key string The key name for the value. `(key)_changed` will be fired when you set value through this method.
    value any any value
    noNotify boolean (optional) True if you want to prevent firing the `(key)_changed` event.
  • bindTo(key, target, targetKey?, noNotify?)

    Bind a key to another object

    Params Type Details
    key string The property name you want to observe.
    target BaseClass The target object you want to observe.
    targetKey string (optional)The property name you want to observe. If you omit this, the `key` argument is used.
    noNotify boolean (optional) True if you want to prevent `(key)_changed` event when you bind first time, because the internal status is changed from `undefined` to something.
  • empty()

    Clears all stored values

  • destroy()

    Executes off() and empty()

  • removeEventListener(eventName?, listener?)

    Remove event listener(s)
    The removeEventListener() has three usages:

    • removeEventListener("eventName", listenerFunction); This removes one particular event listener
    • removeEventListener("eventName"); This removes the event listeners that added for the event name.
    • removeEventListener(); This removes all listeners.
    Params Type Details
    eventName string (optional)event name
    listener function (optional)Event listener
  • off(eventName?, listener?)

    The same as removeEventListener.