Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey hey :) It was cool meeting you in Munich last year, hope all is well!
I've been using Redux a bit more and would like to suggest a couple of changes to this library to make it more slightly flexible yet still "as simple as possible."
Since these would be breaking changes, I'd propose it as a 2.0 release.
Overall, if this isn't your thang, honestly no worries at all. I'd be happy to publish it as a separate package, but thought it'd be cool to try to keep all the number of Redux implementations in DartLand as small as possible, and see what your thoughts are.
Now, I know you didn't want to change to typedef's in my first PR, but hear me out :) This new version would allow us to have our cake and eat it too: If users want to use functions for reducers and middleware, they can. If they want to use classes, they can!
Also, I was trying to implement Redux DevTools, but I was unsuccessful due to the typing of
Action
, because Store Enhancers need to be able todispatch
their own actions. Therefore, I removed it. I had this exact constraint in a Java version of Redux I'd written and and actually removed this Generic constraint in that lib due to the constraint.Proposed changes:
Action
- IfAction
is a typed parameter, it prevents any type of Store Enhancer (such as Redux Dev Tools) from dispatching their own actions. In code, this meansclass Store<State, Action>
becomesclass Store<State>
.typedef State Reducer<State>(State state, dynamic action);
and changesclass Reducer<State, Action>
toabstract class ReducerClass<State>
. This would require only a small change to code, including extending the new class and renamingreduce
tocall
.typedef void Middleware<State>(Store<State> store, dynamic action, NextDispatcher next);
and changesclass Middleware<State, Action>
toabstract class MiddlewareClass<State>
. For middleware, this should be an almost transparent change, as all they'd have to do is extendMiddlewareClass
instead ofMiddleware
.teardown
method, whichclose
s the StreamController and nulls out the state. Needed in case someone wanted to stop using the store during the app lifecycle.Lemme know whatcha think and if you have suggestions!