BlazorFocused 1.0.0-alpha1

This is a prerelease version of BlazorFocused.
There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorFocused --version 1.0.0-alpha1
NuGet\Install-Package BlazorFocused -Version 1.0.0-alpha1
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="BlazorFocused" Version="1.0.0-alpha1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorFocused --version 1.0.0-alpha1
#r "nuget: BlazorFocused, 1.0.0-alpha1"
#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 BlazorFocused as a Cake Addin
#addin nuget:?package=BlazorFocused&version=1.0.0-alpha1&prerelease

// Install BlazorFocused as a Cake Tool
#tool nuget:?package=BlazorFocused&version=1.0.0-alpha1&prerelease

BlazorFocused

Adding Reactive Programming and Flux Architecture to Blazor Components with Microsoft.Extensions.DependencyInjection

Register

Integrate basic store in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();
    services.AddRazorPages();

    // initialized instance of the store's data
    var testClass = new TestClass { FieldOne = "Test" };

    // add store in DI
    services.AddStore(testClass);
}

Integrate store with reducers in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();
    services.AddRazorPages();

    // initialized instance of the store's data
    var testClass = new TestClass { FieldOne = "Test" };

    // add store in DI
    serviceCollection.AddStore(testClass, builder =>
    {
        builder.RegisterReducer(new TestReducer());
    });
}

State

Retrieve static state value from store:

@inject IStore<TestClass> store;

...

store.GetState().FieldOne;

Retrieve state value and subscribe to store updates:

@inject IStore<TestClass> store;

...
TestClass currentState = default;

store.Subscribe((newState) => {
    // update state used in page
    currentState = newState;

    // inform blazor page to refresh with state update
    StateHasChanged();
});

Reducers

Subscribe to reduced value from store:

@inject IStore<TestClass> store;

...
TestClassSubset currentState = default;

store.Reduce<TestClassSubset>(reducedState =>
{
    currentState = reducedState;

    // inform blazor page to refresh with state update
    StateHasChanged();
});

Actions

Register custom actions

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();
    services.AddRazorPages();

    // initialized instance of the store's data
    var testClass = new TestClass { FieldOne = "Test" };

    // add store in DI
    serviceCollection.AddStore(testClass, builder =>
    {
        builder.RegisterAction(new TestAction());
    });
}

Execute actions to update store:

@inject IStore<TestClass> store;

...
TestClass currentState = default;

// call action to be committed
store.Dispatch<TestAction>();

store.Subscribe((newState) => {
    // update state used in page
    currentState = newState;

    // inform blazor page to refresh with state update
    StateHasChanged();
});

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.

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
2.3.0 319 12/11/2022
2.2.2 465 10/19/2022
2.1.1 431 6/20/2022
2.1.0 432 4/20/2022
2.0.0 416 2/22/2022
2.0.0-preview1 143 2/18/2022
2.0.0-beta2 127 2/11/2022
2.0.0-alpha2 138 2/10/2022
2.0.0-alpha1 154 2/3/2022
1.2.2 337 8/25/2021
1.2.1 292 8/24/2021
1.2.0 302 8/22/2021
1.1.2 376 7/16/2021
1.1.1 315 3/27/2021
1.1.0 299 3/27/2021
1.0.1 296 2/19/2021
1.0.0 320 2/15/2021
1.0.0-beta1 288 1/17/2021
1.0.0-alpha2 196 1/16/2021
1.0.0-alpha1 247 1/12/2021

Initial library submission