@twilio/replay-event-emitter
Advanced tools
Comparing version 0.1.0-main.4 to 0.1.0-main.7
{ | ||
"name": "@twilio/replay-event-emitter", | ||
"version": "0.1.0-main.4", | ||
"version": "0.1.0-main.7", | ||
"description": "An extension to Node's EventEmitter that supports event replay.", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -15,12 +15,12 @@ # EventReplayEmitter | ||
```js | ||
import { ReplayEventListener } from "replay-event-listener"; | ||
import { ReplayEventEmitter } from "replay-event-emitter"; | ||
// Instantiate the event listener | ||
const eventListener = new ReplayEventListener(); | ||
// Instantiate the event emitter | ||
const eventEmitter = new ReplayEventEmitter(); | ||
// Emit an event before adding a listener | ||
eventListener.emit("exampleEvent", "someData"); | ||
eventEmitter.emit("exampleEvent", "someData"); | ||
// Subscribe using addListenerWithReplay | ||
eventListener.addListenerWithReplay("exampleEvent", (data) => { | ||
eventEmitter.addListenerWithReplay("exampleEvent", (data) => { | ||
// This handler will get triggered despite the data emission happening BEFORE | ||
@@ -35,3 +35,3 @@ // the event registration. | ||
```js | ||
eventListener.onWithReplay("exampleEvent", (data) => { | ||
eventEmitter.onWithReplay("exampleEvent", (data) => { | ||
console.log(data); | ||
@@ -41,12 +41,12 @@ }); | ||
All the original functionality of the EventListener is still intact: | ||
All the original functionality of the EventEmitter is still intact: | ||
```js | ||
import { ReplayEventListener } from "replay-event-listener"; | ||
import { ReplayEventEmitter } from "replay-event-emitter"; | ||
const eventListener = new ReplayEventListener(); | ||
const eventEmitter = new ReplayEventEmitter(); | ||
eventListener.emit("exampleEvent", "someData"); | ||
eventEmitter.emit("exampleEvent", "someData"); | ||
eventListener.addListener("exampleEvent", (data) => { | ||
eventEmitter.addListener("exampleEvent", (data) => { | ||
// This handler will NOT get triggered, as this is not a replay method and the | ||
@@ -53,0 +53,0 @@ // data emission happened BEFORE the event registration. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54473