Redux 1.0.9

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

// Install Redux as a Cake Tool
#tool nuget:?package=Redux&version=1.0.9

Redux mini for .NET

It's simple "application state" container implementation like Redux for JavaScript.

How does it work?

Application state container is just plain IDictionary<string, object> instance.

You can manage application state with just three methods of Store instance:

public interface Store
{
  void Dispatch(Message message);

  IDictionary<string, object> GetState();

  Action Subscribe(Action<Message> handler);
}

"Send" Message to Store with Dispatch method:


string type = "User";

User user = new User()
{ 
  Email = "joedoe@mail.local" 
};

Message message = new Message(type, user);

store.Dispatch(message);

Get application container state from Store with GetState method:


IDictionary<string, object> state = store.GetState();

User user = state["User"] as User;

Know about application state change with Subscribe method:

public class CustomHandler
{
  private Store store;
    
  public CustomHandler(Store store)
  {
    this.store = store;
  }

  public void Handle(Message message)
  {
    IDictionary<string, object> state = this.store.GetState();

    /// React state change here
  }
}

CustomHandler handler = new CustomHandler(store);

Action unsubscribe = store.Subscribe(handler.Handle);

How to configure own application container?

Make a collection of Reducer-s with built-in tools:

  
List<Reducer> reducers = new List<Reducer>();

reducers.Add(new ReducerImpl("Order"));
reducers.Add(new ReducerImpl("Payment"));
reducers.Add(new ReducerImpl("Withdrawal"));
reducers.Add(new ExceptionReducerImpl());

/// And pass it to constructor of 
/// built-in Store implementation
Store store = new StoreImpl(reducers);

And you are ready to play with your application container. As you can see it knows about four Message types:

  • "Order"
  • "Payment"
  • "Withdrawal"
  • "Exception"

It will ignore any other unknown type Message-s.

Tool to get value from state container

There is built-in StoreValueProvider utility:

Order order = new Order();
Message message = new Message("Order", order);
store.Dispatch(message);

StoreValueProvider provider = new StoreValueProviderImpl();

provider.setStore(store);
provider.setKey("Order");

Assert.Equal(order, provider.get<Order>());
Assert.Equal(order, provider.get(typeof(Order)));

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.2

    • No dependencies.
  • .NETCoreApp 3.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
1.0.11 1,042 11/7/2019
1.0.10 439 11/3/2019
1.0.9 463 11/3/2019
1.0.6 641 7/7/2019
1.0.5 501 7/6/2019
1.0.3 498 7/2/2019
1.0.2 504 6/24/2019
1.0.1 547 6/15/2019
1.0.0 1,065 1/9/2019

netcoreapp3.0 version binary has been added