Redux 1.0.10

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

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

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.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 is compatible.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • 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,119 11/7/2019
1.0.10 454 11/3/2019
1.0.9 476 11/3/2019
1.0.6 653 7/7/2019
1.0.5 513 7/6/2019
1.0.3 507 7/2/2019
1.0.2 515 6/24/2019
1.0.1 566 6/15/2019
1.0.0 1,080 1/9/2019

netstandard2.0 and netstandard2.1 versions binary have been added