Interface InfiniteObjectDispatcherInterface

The InfiniteObjectDispatcherInterface interface is the aggregation of an InfiniteObjectInterface and an EventDispatcherInterface.

The InfiniteObjectDispatcherInterface just provides a new event, ObjectDisposed telling the given object has just been disposed, and that no more references to this object should be kept.

/** 
* Sample to illustrate getting the loading state (updating, ok, out of budget) of the InfiniteEngineInterface.
*/
import { InfiniteEngineInterface, InfiniteEvent, InfiniteObjectDispatcherInterfaceSignal } from 'generated/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;

// what to do when this object is disposed ?
const objectIsDisposed = (_pEvent : InfiniteEvent) : void =>
{
// perhaps some cleanup code and some gui code ?
// detachNode, change dom visibility, etc ...
// there is no need to detach event listeners, event listeners have already been detached (and the current
// event listener will be unbound just after).
console.log('The InfiniteEngineInterface has been cleaned');
}

// bind the event
lInfiniteEngine.addEventListener(InfiniteObjectDispatcherInterfaceSignal.ObjectDisposed, objectIsDisposed);

All future functions called on this object will be a no-op, but a log message with a [LL_UsingDisposedObject](../enums/LogLevel.html#LL_UsingDisposedObject) criticality will be sent (see [InfiniteApiControllerInterface](InfiniteApiControllerInterface.html)).
Main

See

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](InfiniteObjectDispatcherInterface.html#addEventListener) that you want to remove.

    Returns boolean