Interface InfiniteObjectDispatcherInterface

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

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

/** 
* Sample to illustrate the disposal (destruction) of an InfiniteEngineInterface.
*/
import { InfiniteEngineInterface, InfiniteEvent, InfiniteObjectDispatcherInterfaceSignal } from 'generated_files/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);
// and later

lInfiniteEngine.dispose();
// #/: The InfiniteEngineInterface has been cleaned

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

interface InfiniteObjectDispatcherInterface {
    addEventListener(pType, pListener, pObject): string;
    addEventListener(pType, pListener): string;
    areSignalsBlocked(): boolean;
    blockSignals(pBlock): void;
    dispose(): void;
    getInfiniteObjectType(): InfiniteObjectType;
    hasEventListener(pType, pListener): boolean;
    hasEventListenerById(pId): boolean;
    isDisposed(): boolean;
    removeAllEventListeners(): boolean;
    removeEventListener(pType, pListener, pObject): boolean;
    removeEventListener(pType, pListener): boolean;
    removeEventListenerById(pId): boolean;
}

Hierarchy (view full)

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. Calling twice addEventListener with the same parameters results in the second call to be ignored, only unique pairs callback / object are allowed, in order to avoid calling multiple times the same thing.

    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: Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

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

  • 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.

    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

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

  • Tells if signals sent by the object are blocked or not.

    If signals are blocked, no signal will be emitted nor buffered, such signal will be lost.

    Returns boolean

    true if signals are blocked.

  • Blocks / Unblocks all signals sent by the object.

    If signals are blocked, no signal will be emitted nor buffered, such signal will be lost.

    Parameters

    • pBlock: boolean
      in
      If set to true, all further signals will be silently discarded.

    Returns void

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

    Parameters

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

    Returns boolean

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

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

    Parameters

    • pId: string
      in
      The id of the callback to test.

    Returns boolean

    true if such a listener is installed for the given callback id.

  • 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.

    Parameters

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

      The listener function that gets removed.

    • pObject: Object

      The listener object that was used when addEventListener was called.

    Returns boolean

    true if the callback was removed else false.

  • 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.

    Parameters

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

      The listener function that gets removed.

    Returns boolean

    true if the callback was removed else false.

  • 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.

    Parameters

    • pId: string
      in
      The id returned by the call to addEventListener that you want to remove.

    Returns boolean

    true if the callback was removed else false.