Centralized, memory-safe event management for modern JavaScript applications — with throttling, debouncing namespaces, and full observer support.
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.
- Centralized event management
-
once
,throttle
, anddebounce
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
Install using npm
npm install @jamesgober/eventflow
npm run test
npm run coverage
npm run docs
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 });
events.observe('message', (data) => {
console.log('New message received:', data);
});
events.emit('message', { id: 1, text: 'Hello world' });
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 |
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.