oj-event
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

Event

Adds on, once, off and has methods to the Window, Document and Element prototypes.

Usage

import

import "oj-event"

on

on(event: string | string[], cb: Function, opts?: IOptions): this

  • adds the namespaced callback as an eventListener
  • this will override any previous events with the same namespace
  • if event is an array will recursively call on with each event
window.on("click.namespace", e => { ... })

off

off(event: string | string[]): this

  • removes the namespaced event
  • if event is an array will recursively call off with each event
window.off("click.namespace")

has

has(event: string | string[]): boolean

  • returns true if the event or all events are subscribed
window.has("click.namespace")

Types

IOptions

{ 
  preventDefault?: boolean
  stopPropagation?: boolean
  capture?: boolean
  passive?: boolean 
 }

/oj-event/

    Package Sidebar

    Install

    npm i oj-event

    Weekly Downloads

    1

    Version

    6.0.0

    License

    MIT

    Unpacked Size

    10.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • orange-juice