All Projects → lifenautjoe → Noel

lifenautjoe / Noel

Licence: mit
A universal, human-centric, replayable javascript event emitter.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Noel

EventEmitter
Simple EventEmitter with multiple listeners
Stars: ✭ 19 (-87.97%)
Mutual labels:  events, event, event-driven
evon
Fast and versatile event dispatcher code generator for Golang
Stars: ✭ 15 (-90.51%)
Mutual labels:  events, event, event-driven
Laravel Transactional Events
Transaction-aware Event Dispatcher for Laravel
Stars: ✭ 263 (+66.46%)
Mutual labels:  events, dispatcher
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (+103.16%)
Mutual labels:  events, event-driven
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-84.81%)
Mutual labels:  events, event-driven
wishbone
A Python framework to build composable event pipeline servers with minimal effort.
Stars: ✭ 42 (-73.42%)
Mutual labels:  events, event-driven
spa-bus
🔥Tools for multilevel components to pass values in any SPA
Stars: ✭ 15 (-90.51%)
Mutual labels:  events, event
Kledex
.NET Standard framework to create simple and clean design. Advanced features for DDD, CQRS and Event Sourcing.
Stars: ✭ 502 (+217.72%)
Mutual labels:  events, dispatcher
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (-31.65%)
Mutual labels:  events, event
Ease
It's magic.
Stars: ✭ 1,213 (+667.72%)
Mutual labels:  events, event
Opendataday
Open Data Day website
Stars: ✭ 70 (-55.7%)
Mutual labels:  events, event
Pollyjs
Record, Replay, and Stub HTTP Interactions.
Stars: ✭ 9,484 (+5902.53%)
Mutual labels:  replay, browser
event
The implementation of the pattern observer
Stars: ✭ 45 (-71.52%)
Mutual labels:  events, event
cute
An event-centric publisher/subscribe model for objects inspired by the Qt framework
Stars: ✭ 37 (-76.58%)
Mutual labels:  events, event-driven
OpenCQRS
.NET Standard framework to create simple and clean design. Advanced features for DDD, CQRS and Event Sourcing.
Stars: ✭ 546 (+245.57%)
Mutual labels:  events, dispatcher
burns
Manage your application's events without writing spaghetti code
Stars: ✭ 86 (-45.57%)
Mutual labels:  events, event-driven
Sysend.js
Send messages between open pages or tabs in same browser
Stars: ✭ 347 (+119.62%)
Mutual labels:  events, browser
React Native Listener
A utility component to allow easy access to browser native events
Stars: ✭ 136 (-13.92%)
Mutual labels:  events, browser
eventcatalog
Discover, Explore and Document your Event Driven Architectures powered by Markdown.
Stars: ✭ 392 (+148.1%)
Mutual labels:  events, event-driven
UT GameEventSystem
A flexible event system in Unreal Engine 4
Stars: ✭ 33 (-79.11%)
Mutual labels:  event, event-driven
Noel logo

A universal, human-centric, replayable event emitter.

Build Status Human Friendly Coverage Status

Table of Contents

Motivation

The world just like software is full of events. Sometimes these events occur while we are busy doing other things. Wouldn't it be nice to have a way to replay all events? Noel is the way.

By being able to replay events we can design reactive systems without having to worry about timing.

For example, code like

// Check if there is a user in case we missed the userChanged event
const user = sessionService.getUser();
if(user) updateAvatarPhoto(user)

// Listen for further changes
sessionService.listenUserChanged(updateAvatarPhoto);

can become

sessionService.listenUserChanged(doSomethingWithUser).replay();

Meaning that if the userChanged event was already fired, it will be replayed with the last arguments and if it gets fired again, we'll be listening.

Features

  • Event replaying. Never miss a beat.
  • API designed for humans. No useless concepts to try to make sense of.

Installation

npm install noel

Usage

Creating a noel instance

const Noel = require('Noel');

const noel = new Noel();

Emitting and listening to events

// Listen for an event
noel.on('friday', partyAllNightLong);

// Emit an event
noel.emit('friday', arg1, arg2 ....);

Replaying events

// Replay an event once
noel.on(eventName, eventListener).replay();

// Replay an event x amount of times
noel.on(eventName, eventListener).replay(x);

Disabling replay

// When creating the noel instance
const noel = new Noel({
    replay: false
});

// At runtime
noel.disableReplay(anotherBufferSize);

Enabling replay

Please do note that replay is enabled by default, so this should only be necessary if it was disabled at runtime.

// At runtime
noel.enableReplay(anotherBufferSize);

Removing an event listener

noel.removeListener(eventName, eventListener);

or if you save a reference to the eventManager

const eventManager = noel.on('myEvent', eventListener);
// ... 
eventManager.remove();

Removing all event listeners

noel.removeAllListeners(eventName, eventListener);

Clearing an event replay buffer

If you would like to clear all saved event emissions for replay

noel.clearReplayBufferForEvent(eventName);

Clearing all events replay buffers

If you would like to clear all saved events emissions for replay

noel.clearEventsReplayBuffers();

Changing the events replay buffer size

Or in human words, changing the amount of event emissions that are saved for replays.

Default is 1.

// When creating the noel instance
const noel = new Noel({
    replayBufferSize: aNewBufferSize
});

// ...

// At runtime
noel.setReplayBufferSize(anotherBufferSize);

Disabling the no event listeners warning

When an event is emitted, no listeners have been set AND the replay was disabled so there is no way of doing anything with the emission, a warning will be logged into the console if available. To disable this behaviour:

// When creating the noel instance
const noel = new Noel({
    noEventListenersWarning: false
});

// ...

// At runtime
noel.disableNoEventListenersWarning();

Enabling the no event listeners warning

Please do note that the no event listeners warning is enabled by default, so this should only be necessary if it was disabled at runtime.

noel.enableNoEventListenersWarning();

Development

Clone the repository

git clone [email protected]:lifenautjoe/noel.git

Use npm commands

  • npm t: Run test suite
  • npm start: Runs npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't 😉)

Author Joel Hernandez

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].