run-event-handler-once

1.0.2 • Public • Published

run-event-handler-once

npm Travis (.com) branch npm npm bundle size code style: prettier

Register an event handler to a desired target and ensure that the event handler is executed only once.

Installation

Install run-event-handler-once using npm:

npm install --save run-event-handler-once

Or via yarn:

yarn add run-event-handler-once

Usage

const runEventHandlerOnce = require('run-event-handler-once')

const button = document.querySelector('button')

runEventHandlerOnce(button, 'click', function() {
  console.log('Hello!')
})

API

runEventHandlerOnce(target, type, listener, [options])

target

Type: EventTarget

Register an event handler to a desired target.

type

Type: string

The event type.

listener

Type: function

An event handler which receives a notification when an event of the specified type occurs.

options (Optional)

Type: object

An options object that specifies characteristics about the event listener. The available options are:

  • add - An options object that will be passed to addEventListener
  • remove - An options object that will be passed to removeEventListener

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i run-event-handler-once

Weekly Downloads

389

Version

1.0.2

License

MIT

Unpacked Size

3.95 kB

Total Files

4

Last publish

Collaborators

  • neosiae