Class PulseComponent

File

A plugin that allows you to add event listeners on objects. Have your code called alongside an event!

Author

https://github.com/doubleactii

License

Pulse is free software, available under the terms of a MIT style License.

Constructors

Properties

tracker: {
    ids: string[];
    [key: string]: any;
} = ...

Array that tracks events for instances

Type declaration

  • [key: string]: any
  • ids: string[]
storedIDs: string[] = []

Array of stored IDs so that multiple of the same ID cannot be claimed

instanceWeakMap: WeakMap<object, string> = ...

Weakmap to track data belonging to instances used in this module.

version: string = "VERSION_REPLACE_ME"

The version of the module.

logger: any

The logger module this module uses to log errors / logs

Methods

  • Generates a random ID based on the specified length and ensures its uniqueness within the stored IDs.

    Parameters

    • Optional pID: number = 7

      The length of the generated ID.

    Returns string

    A unique random ID.

  • Adds an event listener function to pInstance to call whenever pEventName is called

    Parameters

    • pInstance: any

      The instance to add an event listener to

    • pEventName: string

      The name of the event to add the listener to

    • pFunction: Function

      The function to be called when this event is called

    Returns void

  • Removes an event listener function from pInstance

    Parameters

    • pInstance: any

      The instance to remove the event listener from

    • pEventName: string

      The name of the event to remove

    • pFunction: Function

      The function to be removed

    Returns void

  • Listens for an event on an instance. Preserves any original event function code, while also allowing multiple event listeners to call on the same event.

    Parameters

    • pInstance: any

      The instance that has the event

    • pEventName: string

      The event name to listen for

    Returns void