1.0.1 • Published 6 years ago

event-stack-factory v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

event-stack-factory

Utility for handling global Event Listeners which attached to window

How to use:
Initializing Event Stack
import { eventStackFactory } from 'event-stack-factory';

const EventStack = eventStackFactory(options); // *

See detailed about options *

Pushing new listener to stack

This operation adds new listener to Event Emitter and deletes previous, if exists

const eventListener = event => console.log(event.target.value);

EventStack.push({
  click: eventListener,
  keydown: eventListener,
}) // etc.
Removing listener from stack

This operation deletes latest listener from Event Emitter and sets previous, if exists

EventStack.pop();

If Stack is not empty will fires only last added Event Listener. Useful for "Escape" keydown or "Click" for several opened modal.