Comments (5)
@StevenTCramer It looks like it should be possible to let the store send MediatR messages using a Redux middleware. In that case we could even keep the MediatR integration in a separate NuGet package if we wanted to. This isn't supported at the moment, but I'd be interested in having a look later.
from blazor-redux.
I think this would allow you to keep the main Redux concepts while taking advantage of the C# language benefits. And keeping a separate package makes perfect sense.
The main issue I see is with the composition of Reducers to build the new state. How do you compose the state on all the ReduxActionHandler<>?
from blazor-redux.
I had a similar idea, but I think this is an area where you want your dependencies to be few and tiny. Adding Mediatr, Rx.Main, and AutoMapper quickly begin to grow the size of the app you have to send and run in the browser. Worth trying, but I fear the result is a bloated application dependency that slows everything down.
from blazor-redux.
@StevenTCramer I haven't used MediatR, so I can't really judge whether this is a good idea or not. But if it is, the MediatRedux docs aren't communicating it very convincingly. They argue that instead of switch-like code such as this:
public static int Execute(int state, IAction action)
{
if(action is IncrementAction)
{
return state + 1;
}
if(action is DecrementAction)
{
return state - 1;
}
return state;
}
we should be doing this:
public class IncrementCounter : ReduxAction<State> {}
public class IncrementCounterHandler : ReduxActionHandler<IncrementCounter, State>
{
protected override void HandleAction(State state, IncrementCounter action)
{
state.Counter++;
}
}
public class DecrementCounter : ReduxAction<State> {}
public class DecrementCounterHandler : ReduxActionHandler<DecrementCounter, State>
{
protected override void HandleAction(State state, DecrementCounter action)
{
state.Counter--;
}
}
Anyway, the switch-like reducers don't look too bad in a language like Elm, and with F# it is the same. Even with the pattern matching in C#, it is much nicer than the is/as casting we had before.
I need to look closer into MediatR, though.
from blazor-redux.
@torhovland you may be able to implement this without Rx.Main
if you implement your own IObservable
+IObserver
or ISubject
.
from blazor-redux.
Related Issues (13)
- Blazor 0.5.0 HOT 6
- Nuget package update. HOT 1
- Question: Best alternative to inheriting base class HOT 1
- AddScoped instead of AddSingleton
- It is not compatible with new released Blazor version. HOT 8
- Cannot build from master HOT 2
- Error: System.ArgumentException: The assembly does not contain a public invokable method with [JSInvokableAttribute("DevToolsReady")]. HOT 1
- System.TypeLoadException: Could not resolve type with token 01000030 from typeref (expected class 'Microsoft.JSInterop.Json' in assembly 'Microsoft.JSInterop, Version=0.6.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60')
- Question: Why put async call in the ActionCreator HOT 2
- Linker error when adding package to project. HOT 3
- Is Location now a required Model parameter? HOT 2
- Question: A way to build something like Redux Logger? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazor-redux.