RG.MAUI.Redux
1.0.0
dotnet add package RG.MAUI.Redux --version 1.0.0
NuGet\Install-Package RG.MAUI.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="RG.MAUI.Redux" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RG.MAUI.Redux --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RG.MAUI.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 RG.MAUI.Redux as a Cake Addin #addin nuget:?package=RG.MAUI.Redux&version=1.0.0 // Install RG.MAUI.Redux as a Cake Tool #tool nuget:?package=RG.MAUI.Redux&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RG.MAUI.Redux
A minimal Redux implementation for MAUI projects
Creating Events, Reducer, and Store
// Events
public interface IFooEvent : IEvent { }
public record FooIncremented() : IFooEvent;
public record FooDecremented() : IFooEvent;
public record FooIncrementedBy(int Value) : IFooEvent;
public record FooReset() : IFooEvent;
// Store and Reducer
public record FooStore() : Store<int, IFooEvent>(
reducer: (state, action) =>
action switch {
FooIncremented => state + 1,
FooDecremented => state - 1,
FooIncrementedBy { Value: var val } => state + val,
FooReset => 0,
_ => state_
}.
initialValue: 0
);
// Creating a Store instance
var fooStore = new FooStore();
Reading State
var state = fooStore.State;
Dispatching Event
fooStore.Dispatch(new FooDecremented());
Subscribing to Store updates
var subscription = fooStore.Subscribe(value => {
Console.WriteLine(value);
});
Unsubscribing from Store updates
subscription.Dispose();
Querying Store updates using Reactive.Linq
var query = from value in fooStore
where value % 2 == 0
select value / 2;
var subscription = query.Subscribe(value => {
Console.WriteLine(value);
});
Persisting value to MAUI Preferences
public record PersistedFooStore() : PreferenceStore<int, IFooEvent>(
key: "Foo",
reducer: (state, action) =>
action switch {
FooIncremented => state + 1,
FooDecremented => state - 1,
FooIncrementedBy { Value: var val } => state + val,
FooReset => 0,
_ => state_
}.
initialValue: 0
);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-android31.0 is compatible. net6.0-ios was computed. net6.0-ios13.6 is compatible. net6.0-maccatalyst was computed. net6.0-maccatalyst13.5 is compatible. 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.
-
net6.0
- Microsoft.Maui.Dependencies (>= 6.0.100-rc.1.1608)
- Microsoft.Maui.Extensions (>= 6.0.100-rc.1.1608)
- System.Reactive (>= 5.0.0)
-
net6.0-android31.0
- Microsoft.Maui.Dependencies (>= 6.0.100-rc.1.1608)
- Microsoft.Maui.Extensions (>= 6.0.100-rc.1.1608)
- System.Reactive (>= 5.0.0)
-
net6.0-ios13.6
- Microsoft.Maui.Dependencies (>= 6.0.100-rc.1.1608)
- Microsoft.Maui.Extensions (>= 6.0.100-rc.1.1608)
- System.Reactive (>= 5.0.0)
-
net6.0-maccatalyst13.5
- Microsoft.Maui.Dependencies (>= 6.0.100-rc.1.1608)
- Microsoft.Maui.Extensions (>= 6.0.100-rc.1.1608)
- System.Reactive (>= 5.0.0)
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 | 286 | 9/23/2021 |