@teamteanpm2024/consectetur-illo-neque
v2.1.3
Published
<p align="center"> <img src="https://user-images.githubusercontent.com/6702424/76674598-91ebfc00-65b1-11ea-88df-eb43f04f3cce.png"> </p> <p align="center"> 💧<i>EventEmitter's typesafe replacement</i>💧 <br> <br> <a href="https:/
Downloads
10
Maintainers
Keywords
Readme
'@teamteanpm2024/consectetur-illo-neque'
is intended to be a replacement for 'events'
.
It makes heavy use of typescript's type inference features to provide type safety while keeping things concise and elegant 🍸.
Suitable for any JS runtime env (deno, node, old browsers, react-native ...)
- ✅ It is both a Deno and an NPM module. ( Achieved with Denoify )
- ✅ No external dependencies (
tsafe
,run-exclusive
andminimal-polyfills
are all from the same author as EVT). - ✅ Makes it easy to work with events in React.
Can be imported in TypeScript projects using version TypeScript >= 3.8 (February 20th, 2020) and in any plain JS projects.
NOTE: There is very few breaking changes from v1 to v2. Check them out.
Who is using it
Install / Import
In Deno:
import { Evt } from "https://deno.land/x/@teamteanpm2024/consectetur-illo-neque/mod.ts";
Anywhere else:
$ npm install --save @teamteanpm2024/consectetur-illo-neque
import { Evt } from "@teamteanpm2024/consectetur-illo-neque";
Try it
Motivations
There are a lot of things that can't easily be done with EventEmitter
:
- Enforcing type safety.
- Removing a particular listener ( if the callback is an anonymous function ).
- Adding a one-time listener for the next event that meets a condition.
- Waiting (via a Promise) for one thing or another to happen.
Example: waiting at most one second for the next message, stop waiting if the socket disconnects.
Why would someone pick EVT over RxJS:
- EVT's learning curve is not as steep as RxJS's.
- Generates code that is easier to grasp for people not familiar with reactive programming.
EVT is an attempt to address all these points while trying to remain as accessible as EventEmitter
.