Apps.Contextsphere
7.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Apps.Contextsphere --version 7.0.3
NuGet\Install-Package Apps.Contextsphere -Version 7.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Apps.Contextsphere" Version="7.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Apps.Contextsphere --version 7.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Apps.Contextsphere, 7.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Apps.Contextsphere as a Cake Addin #addin nuget:?package=Apps.Contextsphere&version=7.0.3 // Install Apps.Contextsphere as a Cake Tool #tool nuget:?package=Apps.Contextsphere&version=7.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Overview
Contextsphere provides a lightweight substitute for message bus/hub functionality that is intended for front-end development use.
IMPORTANT: versions 7.0.0 or higher are not compatible with previous ones.
Usage
Register a singleton IContext
in the app's DI container.
...
builder.Services.AddSingleton<IContext, Context>();
...
The same IContext
instance can then be injected anywhere needed:
public class MyNode1 : IHandle<MyItem1, MyResult1, MyParameter1>, ...
{
...
public MyNode1(IContext context, ...)
{
// include this node in the message loop
context.Include(this);
...
}
...
public MyResult1? Handle(MyItem1 item, MyParameter1 param)
{
...
// dispatch an item like so;
contex.Dispatch<MyItemX>(itemX);
// or;
var resultY = context.Dispatch<MyItemY, MyResultY>(itemY);
// or;
var resultZ = context.Dispatch<MyItemZ, MyResultZ, MyParamZ>(itemZ, paramZ);
...
}
}
Apply [ContextNode] attribute to a class for another way to include it in the messaging context.
[ContextNode]
public class MyNode2 : IHandleAsync<MyItem2, MyResult2, MyParameter2>, ...
{
// inject IF NEEDED
// private readonly IServiceProvider serviceProvider;
public async Task<Result<MyResult2>> HandleAsync(MyItem2 item, MyParameter2 param, CancellationToken token)
{
...
// IF NEEDED, get the IContext instance in the IServiceProvider,
var context = serviceProvider.GetService<IContext>() ?? throw new NullReferenceException();
// so you can dispatch an item and await for result like so;
var resultX = await context.DispatchAsync<MyItemX, MyResultX>(itemX, token).ConfigureAwait(false);
// or;
var resultY = await context.DispatchAsync<MyItemY, MyResultY, MyParamY>(itemY, paramY, token).ConfigureAwait(false);
...
}
}
Concerns/Feedbacks?
You may reach me thru jakes_parane@hotmail.ph. Happy coding!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
8.0.1 | 252 | 12/6/2023 | |
7.1.6 | 162 | 11/12/2023 | |
7.1.5 | 124 | 11/12/2023 | |
7.1.4 | 133 | 11/12/2023 | |
7.1.3 | 122 | 11/12/2023 | |
7.1.2 | 112 | 11/12/2023 | |
7.1.1 | 115 | 11/12/2023 | |
7.1.0 | 136 | 11/11/2023 | |
7.0.9 | 129 | 11/11/2023 | |
7.0.8 | 119 | 11/11/2023 | |
7.0.7 | 166 | 10/25/2023 | |
7.0.6 | 158 | 10/25/2023 | |
7.0.5 | 147 | 10/24/2023 | |
7.0.4 | 144 | 10/17/2023 | |
7.0.3 | 157 | 10/15/2023 | |
1.3.4 | 436 | 8/26/2022 |