{"id":21703563,"url":"https://github.com/codemonument/deno_event_bus_core","last_synced_at":"2025-03-20T16:47:46.908Z","repository":{"id":63206771,"uuid":"533059520","full_name":"codemonument/deno_event_bus_core","owner":"codemonument","description":"A deno first library implementing an event bus, published to deno.land/x and cross-posted to npmjs at @codemonument/event-bus-core","archived":false,"fork":false,"pushed_at":"2024-03-31T23:07:25.000Z","size":212,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T06:02:43.013Z","etag":null,"topics":["deno","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/event_bus_core","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/codemonument.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-05T21:03:53.000Z","updated_at":"2024-01-16T17:48:05.000Z","dependencies_parsed_at":"2024-04-01T00:20:57.551Z","dependency_job_id":"85a67dcf-010c-45a4-9342-cfa08a205e77","html_url":"https://github.com/codemonument/deno_event_bus_core","commit_stats":null,"previous_names":["codemonument/event-bus-core"],"tags_count":6,"template":false,"template_full_name":"codemonument/deno_module_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_event_bus_core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_event_bus_core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_event_bus_core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_event_bus_core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonument","download_url":"https://codeload.github.com/codemonument/deno_event_bus_core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244656350,"owners_count":20488638,"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":["deno","typescript"],"created_at":"2024-11-25T21:33:33.739Z","updated_at":"2025-03-20T16:47:46.877Z","avatar_url":"https://github.com/codemonument.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event Bus Core\n\nPublished to:\n\n- https://deno.land/x/event_bus_core (main target)\n- npm: @codemonument/event-bus-core (cross-compiled with dnt)\n- (jsr: @codemonument/event-bus-core directly uploaded) - WIP\n\n## How to Import in Node\n\n```ts\nimport {EventBusRxJS as EventBus} from '@codemonument/event-bus-core';\n```\n\n## How to Import in Deno\n\nNote: Use import url with specific version in production to avoid sudden breaking changes.\n\n```ts\nimport {EventBusRxJS as EventBus} from 'https://deno.land/x/event_bus_core/mod.ts';\n```\n\n## Usage\n\n```ts\nimport {EventBusRxJS as EventBus} from 'https://deno.land/x/event_bus_core';\n\n// Create new EventBus instance\nconst bus = new EventBus();\n\n// Create an empty bus event\nexport class PlainEvent extends BusEvent\u003cvoid\u003e {}\n\n// Create a bus event with payload\nexport interface DemoPayload {\n\tvalue: number;\n}\nexport class EventWithPayload extends BusEvent\u003cDemoPayload\u003e {}\n\n// Subscribe to events\nconst sub1 = bus.on$(PlainEvent).subscribe(() =\u003e {\n\tconsole.log(`Received PlainEvent!`);\n});\n\nconst sub2 = bus.on$(EventWithPayload).subscribe((payload: DemoPayload) =\u003e {\n\tconsole.log(`Received EventWithPayload!`, payload);\n});\n\n// Emit events\nbus.emit(new PlainEvent());\nbus.emit(new EventWithPayload({value: 10}));\n\n// Clean up your rxjs subscriptions!\nsub1.unsubscribe();\nsub2.unsubscribe();\n```\n\n## Advanced Usages\n\nYou can subscribe to the underlying RxJS Observable of this event bus, called bus.eventStream$. \nThis exposes the raw events to you. \nNormally you don't need this and it's better to use the bus.on$ method which filters to a specific event.\n\n```ts\nbus.eventStream$.subscribe((event: unknown) =\u003e {\n\tconsole.log(`Received Event: `, event);\n});\n```\n\nNormally, the `type` key of the BusEvent base-class is auto generated as `this.constructor.name`, which will contain the name of the class extending the BusEvent base-class.\nThis `type` key is used to match the event listeners with the events on the bus.\nHowever, if you have two classes called the same name, this will collide.\nTo avoid this, you can override the `type` key in your event class with a custom string like this:\n\n```ts\nexport class ExplicitTypeEvent extends BusEvent\u003cvoid\u003e {\n\toverride type = 'my-explicit-event-type';\n}\n```\n\n## Todos in this Repo\n\n1. Add test for event-bus.rxjs.ts\n2. Add Code from event-bus-nx package for rx version (esp. EventBus Callback Group)\n3. Rewrite tests for deno\n4. Check if anything still works\n\n## Considerations\n\n## Switching from rxjs to evt\n\n- pro: no rxjs dependency\n- contra: weird evt dependency typings (cross-compiled to deno from node via Denoify)\n- steps:\n  1. Add Evt as dependency in importMap\n  2. Rewrite rxjs usages to evt\n\n## Switchting to standard Webstreams\n\n- pro: standardised spec\n- contra: more difficult to have one stream be sent to mutliple listeners and correctly closing all of them\n\n## Repo Log\n\n### 2022-11-14\n\n- Compilation for npm works now with dnt! https://github.com/denoland/dnt\n- Setup deployment to deno.land/x \u0026 npmjs.org\n\n### 2022-09-05\n\n- Templated from https://github.com/codemonument/deno-module-template/commit/beb8dab612b9c71a7772064353fcd5e2ca9ecd85\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_event_bus_core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonument%2Fdeno_event_bus_core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_event_bus_core/lists"}