{"id":28963427,"url":"https://github.com/sajanv88/simple-mediatr","last_synced_at":"2025-06-24T04:10:09.907Z","repository":{"id":286987520,"uuid":"963176489","full_name":"sajanv88/simple-mediatR","owner":"sajanv88","description":"A lightweight and easy-to-use implementation of the MediatR pattern for .NET Core applications. This library provides a clean and decoupled way to send request,  and publish notifications within your application.","archived":false,"fork":false,"pushed_at":"2025-04-09T10:28:49.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T02:03:19.350Z","etag":null,"topics":["asp-net-core","async-communication","decoupling","notifications"],"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/sajanv88.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-09T09:21:34.000Z","updated_at":"2025-04-27T12:46:05.000Z","dependencies_parsed_at":"2025-04-09T11:22:19.101Z","dependency_job_id":null,"html_url":"https://github.com/sajanv88/simple-mediatR","commit_stats":null,"previous_names":["sajanv88/simple-mediatr"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sajanv88/simple-mediatR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2Fsimple-mediatR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2Fsimple-mediatR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2Fsimple-mediatR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2Fsimple-mediatR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sajanv88","download_url":"https://codeload.github.com/sajanv88/simple-mediatR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2Fsimple-mediatR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261601528,"owners_count":23183097,"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":["asp-net-core","async-communication","decoupling","notifications"],"created_at":"2025-06-24T04:10:09.334Z","updated_at":"2025-06-24T04:10:09.895Z","avatar_url":"https://github.com/sajanv88.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleMediatR\nA lightweight and easy-to-use implementation of the MediatR pattern for\n.NET Core applications. This library provides a clean and decoupled way to send request, \nand publish notifications within your application.\n\nIf you are looking for a simple and effective way to manage communication between components in your .NET Core application, \nSimpleMediatR is the perfect solution.\n\n## ✨ Features\n\n- Supports request/response and notification patterns\n- Decouples business logic using the mediator design pattern\n- Lightweight and minimal dependencies\n- Easy to integrate into existing .NET Core projects\n\n## 📦 Installation\n\n```bash\ndotnet add package SimpleMediatR\n```\n\nOr via NuGet Package Manager:\n\n```powershell\nInstall-Package SimpleMediatR\n```\n\n## 🛠️ Usage\n1. Register MediatR in your DI Container\n```csharp\nbuilder.Services.AddMediatR(); // Automatically registers all handlers in the assembly\n```\n2. Define a Request and its Handler\n\n```csharp\nclass Ping : IRequest\u003cstring\u003e\n{\n    public string Message { get; set; } = string.Empty;\n}\n\nclass PingHandler : IRequestHandler\u003cPing, string\u003e\n{\n    public Task\u003cstring\u003e HandleAsync(Ping request, CancellationToken cancellationToken)\n    {\n        return Task.FromResult($\"Pong: {request.Message}\");\n    }\n}\n\n\nvar ping = new Ping { Message = \"Hello, World!\" };\n\n// Inject `IMediatR  mediatR` then use it\nvar result = await mediatR.SendAsync(ping);\n\nlogger.LogInformation($\"Received response  ({result})\");\n```\n\n## 🔔 Notifications\nYou can also publish notifications to multiple handlers:\n\n```csharp\n\nclass NewUserCreatedEvent : INotification\n{\n    public string FirstName { get; set; } = string.Empty;\n    public string LastName { get; set; } = string.Empty;\n    public Guid Id { get; set; }\n}\n\nclass NewUserNotificationHandler(ILogger\u003cNewUserNotificationHandler\u003e logger) : INotificationHandler\u003cNewUserCreatedEvent\u003e\n{\n    public async Task HandleAsync(NewUserCreatedEvent newUser, CancellationToken cancellationToken)\n    {\n        logger.LogInformation($\"Received notification: FirstName: {newUser.FirstName} LastName: {newUser.LastName} UserId: {newUser.Id}\");\n        await Task.CompletedTask;\n    }\n}\n\n// Publishing when a new user is created\n await mediatR.PublishAsync(new NewUserCreatedEvent\n        {\n            FirstName = request.User.FirstName,\n            LastName = request.User.LastName,\n            Id = request.User.Id\n        }, cancellationToken);\n```\n\n## More examples:\nCheckout the examples folder for more usage examples.\n\n\n## 🤝 Contributing\nContributions are welcome! Feel free to open issues, suggest features, or submit pull requests.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajanv88%2Fsimple-mediatr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsajanv88%2Fsimple-mediatr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajanv88%2Fsimple-mediatr/lists"}