Giter VIP home page Giter VIP logo

Comments (5)

torhovland avatar torhovland commented on September 14, 2024 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.

psampaio avatar psampaio commented on September 14, 2024 1

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.

panesofglass avatar panesofglass commented on September 14, 2024

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.

torhovland avatar torhovland commented on September 14, 2024

@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.

panesofglass avatar panesofglass commented on September 14, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.