1.1.3 • Published 2 years ago

event-awaiter v1.1.3

Weekly downloads
180
License
ISC
Repository
github
Last release
2 years ago

Event Awaiter


Do you have a problem with asynchronous operations where you need to wait for some other event to finish before you continue processing the current one? This package solves this problem.

The package can be used in browser (using EventTarget) or nodejs (using EventEmitter)


Installation

npm i event-awaiter


Usage

const { getEventAwaiter } = require("event-awaiter");
const ea = getEventAwaiter({
  timeout: 20000 // number of milliseconds after event will get rejected
});

const key = "uniqueKey";

const needToBeAwaited = async () => {
  const payload = await ea.setupListener(key); // will be awaited
  console.log(payload);
}

needToBeAwaited();
ea.dispatchEvent(key, "hello world!");

Common Use Cases

  • WebSocket events
  • RabbitMQ events

The package doesn't support IE

1.1.3

2 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago