{"id":24317980,"url":"https://github.com/dawids222/bus-lite","last_synced_at":"2026-06-06T15:02:18.043Z","repository":{"id":65284399,"uuid":"298381401","full_name":"dawids222/Bus-Lite","owner":"dawids222","description":"Small and simple event bus","archived":false,"fork":false,"pushed_at":"2023-01-15T16:43:35.000Z","size":68,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T14:41:25.529Z","etag":null,"topics":["bus","csharp","events","fast","lightweight","net"],"latest_commit_sha":null,"homepage":"","language":"C#","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/dawids222.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-24T19:55:08.000Z","updated_at":"2023-01-16T15:34:35.000Z","dependencies_parsed_at":"2023-01-16T06:15:51.129Z","dependency_job_id":null,"html_url":"https://github.com/dawids222/Bus-Lite","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/dawids222%2FBus-Lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawids222%2FBus-Lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawids222%2FBus-Lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawids222%2FBus-Lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawids222","download_url":"https://codeload.github.com/dawids222/Bus-Lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242902049,"owners_count":20204062,"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":["bus","csharp","events","fast","lightweight","net"],"created_at":"2025-01-17T14:35:53.229Z","updated_at":"2025-03-10T18:29:32.707Z","avatar_url":"https://github.com/dawids222.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bus-Lite\n\nBus-Lite is a small size, high performance tool for objects communication using events. Library is thread safe, written in C# and has no external dependencies.\n\nIt supports 2 different workflows:\n1. Notifying multiple listeners without returning any value\n2. Notifying single handler which returns a value\n\n# Table of contents\n- [Features](#Features)\n- [Examples](#Examples)\n- [Todos](#Todos)\n\n## Features\n\n  - Sending an event to multiple listeners (synchronous, without return value)\n  - Sending an event to a specyfic handler (asynchronous, with return value)\n  - Subscribing listeners\n  - Removing listeners using tokens\n  - Registering handlers\n  - Removing handlers using tokens\n  - Removing all owner's observers at once\n  - Multi-thread  safety\n\n## Examples\n\n ```CSharp\n// creating an instance of an event bus\nvar eventBus = new EventBus();\n```\n\n ```CSharp\n// subscribing listener to an event\n//\n// using Subscribe() we can define multiple listeners for a single event\n// listeners can not return any value\n//\n// first argument is an owner (can not be of type 'ObserverToken')(almost always  'this')\n// second argument is a callback function\n// method retuns token which is used to unsubscribing (so is owner)\nvar eventBus = new EventBus();\nvar token = eventBus.Subscribe\u003cstring\u003e(this, (@event) =\u003e { /* implementation */ });\nvar token2 = eventBus.Subscribe(this, (string @event) =\u003e { /* implementation */ });\nvar token3 = eventBus.Subscribe\u003cstring\u003e(this, new StringEventListener()); // implementation of IEventListener\u003cstring\u003e\nvar token4 = eventBus.Subscribe(this, new StringEventListener()); // implementation of IEventListener\u003cstring\u003e\n```\n\n ```CSharp\n// unsubscribing given listener using it's token\nvar eventBus = new EventBus();\n// ...\nvar token = eventBus.Subscribe\u003cstring\u003e(this, (@event) =\u003e { /* implementation */ });\n// ...\neventBus.Remove(token);\n```\n\n ```CSharp\n// unsubscribing all owner's listeners\nvar eventBus = new EventBus();\n// ...\neventBus.Subscribe\u003cstring\u003e(this, (@event) =\u003e { /* implementation */ });\neventBus.Subscribe\u003cint\u003e(this, (@event) =\u003e { /* implementation */ });\n// ...\neventBus.Remove(this);\n```\n\n```CSharp\n// pushing event to appropriate listeners\n// all required listeners will be notified\nvar eventBus = new EventBus();\n // ...\neventBus.Subscribe\u003cstring\u003e(this, (@event) =\u003e { /* implementation */ });\neventBus.Subscribe\u003cstring\u003e(this, (@event) =\u003e { /* implementation */ });\n// ...\neventBus.Notify(\"example string\");\n```\n```CSharp\n//registering handler to an event\n//\n// using Register() we can define single handler for a single event\n// handlers can return value\n// \n// first argument is an owner (can not be of type 'ObserverToken')(almost always 'this')\n// second argument is a callback function\n// method retuns token which is used to unsubscribing (so is owner)\nvar eventBus = new EventBus();\nvar token = eventBus.Register\u003cIEvent\u003cstring\u003e, string\u003e(this, async (@event) =\u003e await Task.FromResult(\"\"));\nvar token2 = eventBus.Register(this, async (IEvent\u003cstring\u003e @event) =\u003e await Task.FromResult(\"\"));\n var token3 = eventBus.Register\u003cIEvent\u003cstring\u003e, string\u003e(this, new StringEventHandler()); // implementation of IEventHandler\u003cIEvent\u003cstring\u003e, string\u003e\nvar token4 = eventBus.Register(this, new StringEventHandler()); // implementation of IEventHandler\u003cIEvent\u003cstring\u003e, string\u003e\n```\n\n```CSharp\n// unsubscribing given handler using it's token\nvar eventBus = new EventBus();\n// ...\nvar token = eventBus.Register(this, new StringEventHandler());\n// ...\neventBus.Remove(token);\n```\n\n```CSharp\n// pushing event to appropriate handler\n// only one handler will be notified\n// call can be awaited and return a value\n// if no handler was registed for en event an exception will be thrown\nvar eventBus = new EventBus();\n// ...\neventBus.Register(this, new StringEventHandler());\n// ...\nvar @event = new StringEvent(\"\");\nvar result = await eventBus.Handle(@event);\n```\n\n### Todos\n\n - Write MORE Tests\n - Method to temporarily stop listening without unsubscribing","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawids222%2Fbus-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawids222%2Fbus-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawids222%2Fbus-lite/lists"}