core/dispatcher

Provides methods to add and remove global event listeners

import dispatcher from '@enact/core/dispatcher';

Members

offFunction

off(name, fn, target)

Removes a global event listener.

3 Params
name String

Event name

fn Function

Event handler

target Node
default: `document`

Event listener target

onFunction

on(name, fn, target)

Adds a new global event listener. Duplicate event handlers will be discarded.

3 Params
name String

Event name

fn Function

Event handler

target Node
default: `document`

Event listener target

onceFunction

once(name, fn, {target})Function

Adds a new global event listener that removes itself after handling one event.

2 or more Params
name String

Event name

fn Function

Event handler

target Node
optional

Event listener target

Returns
Function

The single-use handler which can be passed to off to remove it.

ArrayBooleanFunctionModuleNumberObjectString