Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Cvent

Index

Constructors

constructor

  • new Cvent(target?: EventTarget): Cvent
  • Parameters

    • Default value target: EventTarget = globalThis

    Returns Cvent

Properties

Private canIUseNative

canIUseNative: boolean

Private debounceEventListeners

debounceEventListeners: Record<string, IFireEvent> | null

Private eventListeners

eventListeners: IEventListener | null

Private target

target: EventTarget | null

Private throttleEventListeners

throttleEventListeners: Record<string, IFireEvent> | null

Static Private defaultMaxListeners

defaultMaxListeners: number = 10

Static Private instance

instance: Cvent | null

Methods

destroy

  • destroy(): void
  • off all events, clear all caches

    Returns void

emit

  • emit(event: string | string[], payload?: any): Cvent
  • emit events Support multiple events(Strings are separated by commas or array of strings)

    Parameters

    • event: string | string[]

      Multiple names of events to be dispatched

    • Default value payload: any = null

      Event handler

    Returns Cvent

emitDebounce

  • emitDebounce(event: string | string[], payload?: any, __namedParameters?: { leading: undefined | false | true; trailing: undefined | false | true; wait: undefined | number }): Cvent
  • emit events by debounce Support multiple events(Strings are separated by commas or array of strings)

    Parameters

    • event: string | string[]

      Multiple event name to be dispatched

    • Default value payload: any = null

      Datas to be dispatched

    • Default value __namedParameters: { leading: undefined | false | true; trailing: undefined | false | true; wait: undefined | number } = {}
      • leading: undefined | false | true
      • trailing: undefined | false | true
      • wait: undefined | number

    Returns Cvent

emitThrottle

  • emitThrottle(event: string | string[], payload?: any, __namedParameters?: { leading: undefined | false | true; trailing: undefined | false | true; wait: undefined | number }): Cvent
  • emit events by throttle Support multiple events(Strings are separated by commas or array of strings)

    Parameters

    • event: string | string[]

      Multiple event name to be dispatched

    • Default value payload: any = null

      Datas to be dispatched

    • Default value __namedParameters: { leading: undefined | false | true; trailing: undefined | false | true; wait: undefined | number } = {}
      • leading: undefined | false | true
      • trailing: undefined | false | true
      • wait: undefined | number

    Returns Cvent

Private fireEvent

  • fireEvent(ev: string, payload: any): void
  • Real logic of single event to be dispatched

    Parameters

    • ev: string

      Single event name

    • payload: any

      Datas to be dispatched

    Returns void

getMaxListeners

  • getMaxListeners(): number

off

  • cancel events Support multiple events(Strings are separated by commas or array of strings) Support to cancel a type of event (only pass the event name, not pass the event processing function)

    Parameters

    • event: string | string[]

      Multiple names of events to be canceled

    • Optional eventlistener: ICustomEventListener

      Event handler

    Returns Cvent

on

  • register events Support multiple events(Strings are separated by commas or array of strings)

    Parameters

    • event: string | string[]

      Multiple names of events to be registered

    • eventlistener: ICustomEventListener

      Event handler

    • Default value options: IOnOptions = { once: false }

    Returns Cvent

once

  • register events will to be called once Support multiple events(Strings are separated by commas or array of strings)

    Parameters

    Returns Cvent

setMaxListeners

  • setMaxListeners(maxListeners: number): void
  • Parameters

    • maxListeners: number

    Returns void

Static getInstance

  • getInstance(target?: EventTarget): Cvent
  • Support return singleton

    Parameters

    • Default value target: EventTarget = globalThis

    Returns Cvent

Legend

  • Constructor
  • Method
  • Private property
  • Private method
  • Property
  • Static method

Generated using TypeDoc