Naravel.Notifications
0.2.0
dotnet add package Naravel.Notifications --version 0.2.0
NuGet\Install-Package Naravel.Notifications -Version 0.2.0
<PackageReference Include="Naravel.Notifications" Version="0.2.0" />
<PackageVersion Include="Naravel.Notifications" Version="0.2.0" />
<PackageReference Include="Naravel.Notifications" />
paket add Naravel.Notifications --version 0.2.0
#r "nuget: Naravel.Notifications, 0.2.0"
#:package Naravel.Notifications@0.2.0
#addin nuget:?package=Naravel.Notifications&version=0.2.0
#tool nuget:?package=Naravel.Notifications&version=0.2.0
Naravel.Notifications
Typed notification fan-out over explicitly named channels, with a fake for tests. Channels (Mail, Queue) are separate opt-in packages.
| Fact | Detail |
|---|---|
| Install | dotnet add package Naravel.Notifications |
| Targets | .NET 10 |
| Needs | No other Naravel package |
| Channels | mail and queued delivery are separate opt-in packages: Naravel.Notifications.Mail and Naravel.Notifications.Queue |
What you get
- One typed notification, the channels you name.
SendAsync(recipient, notification, ["log"], ct)delivers through the named channels, in the order you name them. - A channel is a class or a delegate. A class implements
INotificationChannel<T>and is resolved from DI per scope, so it can take dependencies. - A built-in log channel.
AddLogNotificationChannel<T>()logs the type names only. - Plain recipients. The recipient is any object; it is passed to the channels as is.
- A test fake.
NotificationFakeis anINotificationSenderthat delivers nothing, for assertions in tests.
Quick start
using Naravel.Notifications;
builder.Services.AddNaravelNotifications();
builder.Services.AddLogNotificationChannel<InvoiceReady>(); // a channel named "log"
app.MapPost("/invoices/{id:int}/notify", async (int id, INotificationSender notifications, CancellationToken ct) =>
{
var recipient = new User("Ada"); // any object: it is passed to the channels as is
await notifications.SendAsync(recipient, new InvoiceReady(id), ["log"], ct);
return Results.Accepted();
});
public sealed record User(string Name);
public sealed record InvoiceReady(int InvoiceId);
A channel is registered per notification type and chosen by name on every call; nothing is inferred from the recipient or from registration order.
Related packages
| Package | Adds |
|---|---|
Naravel.Notifications.Mail |
Optional Naravel.Notifications adapter: a "mail" channel that delivers a notification through Naravel.Mail. |
Naravel.Notifications.Queue |
Optional Naravel.Notifications adapter that delivers notifications through Naravel.Queue: only a registered alias and a plain payload are stored. |
Learn more
- Notifications: English guide
- Changelog · Source and issues · MIT license
Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Naravel.Notifications:
| Package | Downloads |
|---|---|
|
Naravel.Notifications.Queue
Optional Naravel.Notifications adapter that delivers notifications through Naravel.Queue: only a registered alias and a plain payload are stored. |
|
|
Naravel.Notifications.Mail
Optional Naravel.Notifications adapter: a "mail" channel that delivers a notification through Naravel.Mail. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes: https://github.com/km-arc/Naravel/releases/tag/v0.2.0 - full history: https://github.com/km-arc/Naravel/blob/main/CHANGELOG.md