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.
<PackageVersion Include="BlazorFocused" Version="1.0.0-alpha1" />
                    
Directory.Packages.props
<PackageReference Include="BlazorFocused" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package BlazorFocused@1.0.0-alpha1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorFocused&version=1.0.0-alpha1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=BlazorFocused&version=1.0.0-alpha1&prerelease
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
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 450 12/11/2022 2.3.0 is deprecated because it is no longer maintained.
2.2.2 560 10/19/2022
2.1.1 534 6/20/2022
2.1.0 541 4/20/2022
2.0.0 526 2/22/2022
2.0.0-preview1 246 2/18/2022
2.0.0-beta2 233 2/11/2022
2.0.0-alpha2 241 2/10/2022
2.0.0-alpha1 254 2/3/2022
1.2.2 452 8/25/2021
1.2.1 397 8/24/2021
1.2.0 416 8/22/2021
1.1.2 494 7/16/2021
1.1.1 440 3/27/2021
1.1.0 412 3/27/2021
1.0.1 414 2/19/2021
1.0.0 440 2/15/2021
1.0.0-beta1 401 1/17/2021
1.0.0-alpha2 321 1/16/2021
1.0.0-alpha1 364 1/12/2021

Initial library submission