BlazorFocused.Reactive.Redux 1.0.0

dotnet add package BlazorFocused.Reactive.Redux --version 1.0.0                
NuGet\Install-Package BlazorFocused.Reactive.Redux -Version 1.0.0                
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.Reactive.Redux" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorFocused.Reactive.Redux --version 1.0.0                
#r "nuget: BlazorFocused.Reactive.Redux, 1.0.0"                
#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.Reactive.Redux as a Cake Addin
#addin nuget:?package=BlazorFocused.Reactive.Redux&version=1.0.0

// Install BlazorFocused.Reactive.Redux as a Cake Tool
#tool nuget:?package=BlazorFocused.Reactive.Redux&version=1.0.0                

Nuget Version Nuget Downloads

BlazorFocused Reactive Redux

Provides one single source of updating and retrieving a data store throughout entire application

NuGet Packages

Package Description
BlazorFocused.Reactive.Redux Provides one single source of updating and retrieving a data store throughout entire application

Documentation

Please visit the BlazorFocused.Reactive Documentation Site for installation, getting started, and API documentation.

Samples

Please visit and/or download our BlazorFocused.Reactive.Redux Sample Solution to get a more in-depth view of usage.

Installation

dotnet add package BlazorFocused.Reactive.Redux

Quick Start

Blazor WebAssembly Startup

public static async Task Main(string[] args)
{
    var builder = WebAssemblyHostBuilder.CreateDefault(args);
    builder.RootComponents.Add<App>("#app");

    builder.Services.AddScoped(sp =>
        new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

    builder.Services.AddStore<TestStore>(new TestStore { FieldOne = "Initialized" })
        .AddTransient<TestAction>()
        .AddTransient<TestActionAsync>()
        .AddTransient<TestReducer>()
        .AddScoped<TestService>()
        .AddSingleton<TestSingletonService>();
    await builder.Build().RunAsync();
}

State

Retrieve static state value from store:

@inject IStore<TestStore> store;
...
store.GetState().FieldOne;

Retrieve state value and subscribe to store updates:

@inject IStore<TestStore> store;
...
TestStore 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<TestStore> store;
...
TestStoreSubset subsetState = default;
store.Reduce<TestReducer, TestStoreSubset>(reducedState =>
{
    // helpful if you do not care about the full state in your component
    subsetState = reducedState;
    // inform blazor page to refresh with state update
    StateHasChanged();
});

Actions

Execute actions to update store:

@inject IStore<TestStore> store;
...
TestStore currentState = default;
// call action to be committed
// if action updates state, component will update
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 net6.0 is compatible.  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 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 is compatible.  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
1.0.0 123 2/27/2024
1.0.0-alpha1 82 9/29/2023