@okiba/event-manager

Centralized event management

Usage no npm install needed!

<script type="module">
  import okibaEventManager from 'https://cdn.skypack.dev/@okiba/event-manager';
</script>

README

Okiba / EventManager

A custom events management system

Installation

npm i --save @okiba/event-manager

Or import it directly in the browser

<script type="module" src="https://unpkg.com/@okiba/event-manager/index.js"></script>

Usage

import EventManager from '@okiba/event-manager'

Untranspiled code 🛑

Okiba UI packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:

{
  test: /\.js$/,
  exclude: /node_modules\/(?!(@okiba)\/).*/,
  use: {
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env']
    }
  }
}

Submodules:

EventManager

A singleton to manage centralized event listeners

subscribedEvents, hasListeners, subscribe, unsubscribe, update, on, off, emit, clear, destroy

AbstractHandler

A base class that defines a global event handler interface

module:AbstractHandler, eventCallback, listen, unlisten, dispatch

EventHandler

An handler class aimed to centralize a native browser event listener

listen, unlisten, dispatch

RAFHandler

An handler class aimed to centralize a requestAnimationFrame

nextFrame, listen, unlisten