Skip to content

A fast, flexible JavaScript event system with namespacing, throttling, debouncing, observables, and debug tools — built for performance.

License

Notifications You must be signed in to change notification settings

jamesgober/event-flow

Repository files navigation

Triple Hexagon

EVENT FLOW
JAVASCRIPT EVENT MANAGER

Centralized, memory-safe event management for modern JavaScript applications — with throttling, debouncing namespaces, and full observer support.


NPM Version   NPM Downloads   CommonJS Badge   GitHub

EventFlow is a high-performance, memory-efficient event management layer built to replace messy DOM bindings and tangled listener logic. Instead of scattering addEventListener all over your UI, EventFlow gives you a centralized, declarative system for managing app-wide events with namespaces, throttling, debouncing, and observer support built right in.

Ideal for reactive designs/interfaces, modular UIs, and JavaScript apps that demand control and consistency, EventFlow gives you the speed and structure of an event bus—without the bulk of bloated frameworks or the chaos of raw DOM wiring.


Features

  • Centralized event management
  • once, throttle, and debounce support
  • Namespaced event listeners (on('click', fn, { namespace: 'ui' }))
  • Observer pattern (observe, unobserve)
  • Full test coverage (Jest)
  • No DOM pollution — pure logic, clean memory
  • Built-in error protection with doEvent
  • Works in Node.js, Browser, JSDOM, and Hybrid environments


Usage

Install using npm

npm install @jamesgober/eventflow

Running Tests

npm run test
npm run coverage

Documentation

npm run docs

Basic Usage

const EventFlow = require('@jamesgober/eventflow'); // or import if you use ESM
const events = new EventFlow({ debug: true });

events.on('save', () => console.log('Saved!'));
events.emit('save');

events.on('scroll', () => console.log('Scrolled!'), { throttle: 250 });
events.on('submit', () => console.log('Form submitted!'), { once: true });

Observers (reactive-style):

events.observe('message', (data) => {
  console.log('New message received:', data);
});

events.emit('message', { id: 1, text: 'Hello world' });

API Summary

Method

Description

on() Register an event listener with optional modifiers
off() Remove a listener by reference
emit() Trigger an event with optional arguments
observe() Register an observer that watches all emits
unobserve() Remove an observer from an event
_throttle() Internal helper for throttling
_debounce() Internal helper for debouncing
_applyModifiers() Wraps listeners with debounce/throttle/once logic



License

This is an open-source project licensed under the MIT license.

All rights not explicitly granted in the MIT license are reserved. You may obtain a copy of the License at: https://opensource.org/licenses/MIT.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.


See the LICENSE file included with this project for the specific language governing permissions and limitations under the License.




COPYRIGHT © 2025 JAMES GOBER.

About

A fast, flexible JavaScript event system with namespacing, throttling, debouncing, observables, and debug tools — built for performance.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published