Détail du package

evt

garronej297.8kMIT2.5.9

Type safe replacement for node's EventEmitter

deno, EventEmitter, typescript, functional programming

readme

💧EventEmitter's typesafe replacement💧

Home - Documentation


'evt' 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 ...)

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/evt/mod.ts";

Anywhere else:

$ npm install --save evt
import { Evt } from "evt";

Try it


Playground

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.


Get Started

The sticker


Shop

changelog

1.9.8 (2020-11-16)

  • Add nonNullable operator

1.9.7 (2020-11-15)

  • Add tools/typeSafety/PromiseOrNot helper type

1.9.6 (2020-11-15)

  • Improve Evt.asyncPipe()

1.9.5 (2020-11-14)

  • Ensure semantic guarantee for hooks/useEvt

1.9.4 (2020-11-10)

  • Add the Id helper type in tools/typeSafety/id

1.9.3 (2020-11-09)

  • Add tools/typeSafety/MethodNames

1.9.2 (2020-10-29)

  • Improve error stack trace of tools/typeSafety/assert

1.9.1 (2020-10-28)

  • Make EventEmitter.removeListener easily emulable

1.9.0 (2020-10-24)

  • Add evt.postAndWait()

1.8.11 (2020-10-22)

  • Fix TypeScript error in Evt.asNonPostable.d.ts '=' expected. TS1005 (create-react-app) Use of import type was breaking the TypeScript retroconpatibility.

1.8.10 (2020-09-14)

  • Merge pull request #14 from garronej/issue-12-support-strict-type-import-export

Issue 12 support strict type import export ( fix for retrocompat )

  • Use --unstable flag to run tests
  • CI workflow runs test on Windows as well
  • fix: missed some fix: add type imports to test files
  • fix: use import/export type syntax for types
  • Merge pull request #11 from garronej/dependabot/npm_and_yarn/node-fetch-2.6.1

Bump node-fetch from 2.6.0 to 2.6.1

  • Update README.md
  • Update README.md

1.8.9 (2020-09-03)

  • add Evt.asyncPipe (as a static method until async operator lands)

1.8.8 (2020-08-28)

  • Hooks denoified as well
  • Update README.md

1.8.6 (2020-08-08)

  • Advertise React Hooks integration

1.8.5 (2020-08-07)

  • Merge pull request #8 from garronej/dependabot/npm_and_yarn/lodash-4.17.19

Bump lodash from 4.17.15 to 4.17.19

  • Fix issue #9: Bug with Evt.from(window,...)

1.8.4 (2020-08-05)

  • Switch back to tag name prefixed with 'v'
  • fix useEvt hook for verry slow browser

1.8.3 (2020-07-31)

  • Add documentation for react hooks

1.8.2 (2020-07-31)

  • Fix for useEvt on Safari

1.8.1 (2020-07-28)

  • fix bug in hooks/useStatefulEvt
  • Add missing 'attachExtract' overloads

1.8.0 (2020-07-24)

  • Add hooks for react integration

1.7.14 (2020-07-19)

  • update dependencies

1.7.13 (2020-06-14)

  • Add JSDoc link to Evt.merge
  • update deps
  • Update project description
  • Reference Denoify in the readme
  • include who is using it sectiion

1.7.12 (2020-05-30)

  • Reference Denoify in the readme
  • Update README.md

1.7.11 (2020-05-25)

1.7.11 (2020-05-25)

  • Re include source map without breaking TS retro compatibility

1.7.10 (2020-05-25)

  • Fix: Include CDN build

1.7.9 (2020-05-24)

  • Do not include source in the NPM bundle for TS retro compatibility (they will be re-included later)

1.7.8 (2020-05-24)

  • Remove nullish coalescing from source for stackblitz compat

1.7.7 (2020-05-24)

  • Not including source test files in the NPM bundle
  • readme typo fix

1.7.6 (2020-05-23)

  • Make the README links visible on deno.land/x
  • Merge pull request #7 from searchableguy/develop
  • Add a note in overview about difference between attach and $attach
  • Update run-exclusive

1.7.5 (2020-05-23)

  • Bump version ( changelog ignore )
  • Use test/mod.ts instead of test/index_deno.ts to align with conventions
  • Enable source map, 'Go to Definition' navigate to .ts source file instead of .d.ts file
  • Revert back to the old type import syntax and regain support for TS 3.4 - 3.7, WARNING: This release do not work with Deno 1.0.1 but do work with 1.0.2
  • Typo fixes

1.7.4 (2020-05-22)

  • GitBook: [develop] one page modified
  • instruct to refer to CHANGELOG.md
  • GitBook: [develop] one page modified
  • GitBook: [develop] 32 pages and one asset modified

1.7.3 (2020-05-21)

  • fix for supporting Deno v1.0.1, temporary dropping support for TS < 3.8

1.7.2 (2020-05-21)

  • Notice about the fact EVT won't work on Deno 1.0.1
  • GitBook: [develop] 17 pages and one asset modified

1.7.1 (2020-05-21)

  • Temporarily disabling sourcemaps
  • Add CI badge

1.7.0 (2020-05-21)

  • Includes CDN build to import from HTML.
  • Enable short path ( Breaking change ) evt/dist/tools/typeSafety => evt/tools/typeSafety