marcglasberg / async_redux

Flutter Package: A Redux version tailored for Flutter, which is easy to learn, to use, to test, and has no boilerplate. Allows for both sync and async reducers.
Other
230 stars 41 forks source link

WaitAction with BuiltValue #64

Closed raphaelColleau closed 4 years ago

raphaelColleau commented 4 years ago

Hello,

I like very much the WaitAction because when you have a lot a loading it can pollute you state classes. But I use BuiltValue for immutability of the State and i think it's a popular choice among dart devs. Could you add a way to make it work with BuiltValue ?

Maybe something like this

try {
    return (state as dynamic).rebuild((state) => 
        state..wait = state.wait.process(operation, flag: flag, ref: ref));
} catch (_) {
      return (state as dynamic).copy(wait: wait.process(operation, flag: flag, ref: ref));
}
marcglasberg commented 4 years ago

WIth the help of @knaeckeKami I have developed a solution that may work for both BuiltValue and Freezed packages, and also lets you inject your own reducer if necessary.

I don't use BuiltValue myself so I can't test it. Could you please test if version 2.7.1 (in GutHub only, not yet uploaded to pub) works as it should with BuiltValue?

raphaelColleau commented 4 years ago

I just tried it and it's working perfectly ! Thanks