{"id":15439752,"url":"https://github.com/bcherny/typed-rx-emitter","last_synced_at":"2025-04-19T18:49:43.392Z","repository":{"id":55107762,"uuid":"81392506","full_name":"bcherny/typed-rx-emitter","owner":"bcherny","description":"Typesafe RxJS-based EventEmitter","archived":false,"fork":false,"pushed_at":"2018-11-14T09:22:16.000Z","size":210,"stargazers_count":27,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T23:53:47.322Z","etag":null,"topics":["emitter","event","eventemitter","javascript","rx","rxjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcherny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-09T00:55:27.000Z","updated_at":"2022-08-09T09:51:09.000Z","dependencies_parsed_at":"2022-08-14T12:10:46.752Z","dependency_job_id":null,"html_url":"https://github.com/bcherny/typed-rx-emitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-rx-emitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-rx-emitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-rx-emitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcherny%2Ftyped-rx-emitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcherny","download_url":"https://codeload.github.com/bcherny/typed-rx-emitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249769594,"owners_count":21323067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emitter","event","eventemitter","javascript","rx","rxjs","typescript"],"created_at":"2024-10-01T19:09:15.833Z","updated_at":"2025-04-19T18:49:43.361Z","avatar_url":"https://github.com/bcherny.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"typed-rx-emitter: Typesafe Rx-based event emitter\" src=\"https://raw.githubusercontent.com/bcherny/typed-rx-emitter/master/logo.png\" width=\"320px\" /\u003e\n\n[![Build Status][build]](https://circleci.com/gh/bcherny/typed-rx-emitter) [![npm]](https://www.npmjs.com/package/typed-rx-emitter) [![mit]](https://opensource.org/licenses/MIT) [![ts]](https://www.typescriptlang.org/) [![flow]](https://flow.org/)\n\n[build]: https://img.shields.io/circleci/project/bcherny/typed-rx-emitter/master.svg?style=flat-square\n[npm]: https://img.shields.io/npm/v/typed-rx-emitter.svg?style=flat-square\n[mit]: https://img.shields.io/npm/l/typed-rx-emitter.svg?style=flat-square\n[ts]: https://img.shields.io/badge/TypeScript-%E2%9C%93-007ACC.svg?style=flat-square\n[flow]: https://img.shields.io/badge/Flow-%E2%9C%93-007ACC.svg?style=flat-square\n\n\n## Highlights\n\n- 100% typesafe:\n  - Statically enforces that channels in `.on()` are defined\n  - Statically enforces that channels in `.emit()` are defined\n  - Statically enforces that emitters are called with the correct data given their Message name\n  - Statically enforces that listeners are called with the correct data given their Message name\n- Supports [all RxJS Observable methods](http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html)\n- Supports RxJS versions 4, 5, and 6\n- Preforms dynamic analysis to detect and warn about cycles in emitters\n- 3.7kb gzipped \u0026 minified (using RxJS6), including RxJS\n\n## Installation (with RxJS v5.x or v6.x - recommended)\n\n```sh\n# Using Yarn:\nyarn add typed-rx-emitter rxjs\n\n# Using NPM:\nnpm install typed-rx-emitter rxjs --save\n```\n\n## Installation (with RxJS v4.x)\n\n```sh\n# Using Yarn:\nyarn add typed-rx-emitter@^0.3\n\n# Using NPM:\nnpm install typed-rx-emitter@^0.3 --save\n```\n\n## Usage\n\n```ts\nimport { Emitter } from 'typed-rx-emitter'\n\n// Enumerate messages\ntype Messages = {\n  INCREMENT_COUNTER: number\n  OPEN_MODAL: boolean\n}\n\nconst emitter = new Emitter\u003cMessages\u003e()\n\n// Listen on an event (basic)\nemitter\n  .on('OPEN_MODAL')\n  .subscribe(_ =\u003e console.log(`Change modal visibility: ${_}`)) // _ is a boolean\n\n// Listen on an event (advanced)\nimport { debounceTime, filter } from 'rxjs/operators'\n\nemitter\n  .on('INCREMENT_COUNTER')\n  .pipe(\n    filter(_ =\u003e _ \u003e 3), // _ is a number\n    debounceTime(100)\n  )\n  .subscribe(_ =\u003e console.log(`Counter incremented to ${_}`)) // _ is a number\n\n// Listen on all events\nemitter\n  .all()\n  .subscribe(() =\u003e console.log('Something changed'))\n\n// Trigger an event - throws a compile time error unless id and value are set, and are of the right types\nemitter.emit('OPEN_MODAL', true)\n\n// Event is misspelled - throws a compile time error\nemitter.emit('INCREMENT_CONTER')\n```\n\nSee a complete browser usage example [here](https://github.com/bcherny/typed-rx-emitter/blob/master/browser-example).\n\n## Options\n\n`Emitter` takes an optional `options` argument. `options` is an object, and each key in the object is optional:\n\n| Option | Default | Description |\n|-|-|-|\n| `Error` | `CyclicalDependencyError` | Custom Error subclass for cycle warning |\n| `isDevMode` | `false` | Perform dynamic analysis to warn about cycles? |\n\n## Tests\n\n```sh\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcherny%2Ftyped-rx-emitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcherny%2Ftyped-rx-emitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcherny%2Ftyped-rx-emitter/lists"}