Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IEventified

Objects those implement this interface have essentially the capability to process events.

Hierarchy

  • IEventified

Index

Methods

emit

  • emit(type: EventType, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any): void
  • Trigger an event directly with the event name and necessary arguments.

    Parameters

    • type: EventType

      event type

    • Optional arg0: any
    • Optional arg1: any
    • Optional arg2: any
    • Optional arg3: any
    • Optional arg4: any

    Returns void

hasEventListener

  • hasEventListener(type: string, callback?: Function, target?: undefined | object): boolean
  • Checks whether there is correspond event listener registered on the given event.

    Parameters

    • type: string

      Event type.

    • Optional callback: Function

      Callback function when event triggered.

    • Optional target: undefined | object

      Callback callee.

    Returns boolean

off

  • Removes the listeners previously registered with the same type, callback, target and or useCapture, if only type is passed as parameter, all listeners registered with that type will be removed.

    example

    import { log } from 'cc'; // register fire eventListener var callback = eventTarget.on('fire', function () { log("fire in the hole"); }, target); // remove fire event listener eventTarget.off('fire', callback, target); // remove all fire event listeners eventTarget.off('fire');

    Type parameters

    • TFunction: Function

    Parameters

    • type: EventType

      A string representing the event type being removed.

    • Optional callback: TFunction

      The callback to remove.

    • Optional thisArg: any

    Returns void

on

  • on<TFunction>(type: EventType, callback: TFunction, thisArg?: any, once?: undefined | false | true): typeof callback
  • Register an callback of a specific event type on the EventTarget. This type of event should be triggered via emit.

    example

    import { log } from 'cc'; eventTarget.on('fire', function () { log("fire in the hole"); }, node);

    Type parameters

    • TFunction: Function

    Parameters

    • type: EventType

      A string representing the event type to listen for.

    • callback: TFunction

      The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).

    • Optional thisArg: any

      The target (this object) to invoke the callback, can be null

    • Optional once: undefined | false | true

    Returns typeof callback

    • Just returns the incoming callback so you can save the anonymous function easier.

once

  • once<TFunction>(type: EventType, callback: TFunction, thisArg?: any): typeof callback
  • Register an callback of a specific event type on the EventTarget, the callback will remove itself after the first time it is triggered.

    example

    import { log } from 'cc'; eventTarget.once('fire', function () { log("this is the callback and will be invoked only once"); }, node);

    Type parameters

    • TFunction: Function

    Parameters

    • type: EventType

      A string representing the event type to listen for.

    • callback: TFunction

      The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).

    • Optional thisArg: any

    Returns typeof callback

removeAll

  • removeAll(typeOrTarget: string | object): void
  • Removes all callbacks registered in a certain event type or all callbacks registered with a certain target

    Parameters

    • typeOrTarget: string | object

      The event type or target with which the listeners will be removed

    Returns void

targetOff

  • targetOff(typeOrTarget: string | object): void
  • Removes all callbacks previously registered with the same target (passed as parameter). This is not for removing all listeners in the current event target, and this is not for removing all listeners the target parameter have registered. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.

    Parameters

    • typeOrTarget: string | object

      The target to be searched for all related listeners

    Returns void

Generated using TypeDoc