Closed lasseschmitt closed 6 years ago
I get a similar issue when dispatching actions using my store:
I/flutter ( 3621): The following assertion was thrown while handling a gesture: I/flutter ( 3621): type '(AppState, ChangeViewAction) => AppState' is not a subtype of type '(AppState, dynamic) => I/flutter ( 3621): AppState'
I believe changes to the redux_dart library need to be made in order to bring it up to speed with Dart 2, i'll try to investigate further
Thanks for the reports! I'll try to find time soon to look into the issues :)
@DrivEddy Hrm, are you passing the onBoardingReducer
directly to the store? This is a curious case. I've run the tests again using the latest version of the Dart SDK from Flutter, which cover reducers and combining reducers, and the tests are currently passing.
@envious Are you also using combineTypedReducer
? Could you please provide the signature of your Reducer?
If either of you are providing your own Reducer to the store (not one generated by combineTypedReducers
), it must match the signature (State, dynamic) -> State
. You cannot provide your own type signature for the action
parameter, as this would break 3rd party libraries that need to dispatch actions. If combineTypedReducers
is returning the wrong type signature, then we might need to submit a bug report to the dart SDK repo, since it returns a function of that signature.
My Store looks like this
final store = new Store<AppState>(
appStateReducer,
initialState: new AppState.init(),
middleware: createStoreMiddleware()
);
class AppState {
final FirebaseUser firebaseUser;
final OnBoardingState onBoardingData;
....
}
AppState appStateReducer(AppState state, action) {
return new AppState(
firebaseUser: authReducer(state.firebaseUser, action),
onBoardingData: onBoardingReducer(state.onBoardingData, action),
);
}
And as in #3 I noticed I didn't turn on --preview-dart-2
but the dart2 features like AwesomeClass()
instead of new AwesomeClass()
where available anyway. Do you think that could be somehow related?
Hrm, that's an interesting one! If you add the typing to the action
in your appStateReducer then all should be good for Dart 2. E.g.
AppState appStateReducer(AppState state, dynamic action) {
If you're on master branch, it should be running Dart2 by default now, so you don't need to add the flag.
Unfortunalty no -_-
Even if I add dynamic
to AppState appStateReducer(AppState state, dynamic action)
I still get
error is happend type '(OnBoardingState, LicensesLoadedAction) => OnBoardingState' is not a subtype of type '(OnBoardingState, dynamic) => OnBoardingState'
Thanks for the reports! Sorry about these issues. I've found that all tests pass using the standalone Dart 2 SDK, but fail using Flutter test. Redux runs all its tests using the standalone SDK since it's a pure dart lib, but this might be hiding an error, or Flutter might be running into an error.
I've filed a bug on the repo: https://github.com/flutter/flutter/issues/15900
I encounter the same issue
I/flutter ( 5391): type '(IdentityState, LoginSuccessfulAction) => IdentityState' is not a subtype of type I/flutter ( 5391): '(IdentityState, dynamic) => IdentityState
on
Flutter 0.2.5-pre.55 • channel master • https://github.com/flutter/flutter.git
Framework • revision 39eeec47d6 (13 hours ago) • 2018-03-27 15:27:24 -0700
Engine • revision 3e877d371a
Tools • Dart 2.0.0-dev.40.0.flutter-06949dc985
Thanks for the report @dodyg!
As a heads up, I'm waiting on a response from the Flutter team to see if they can help us out here. Hard to know if this is a legit type issue that needs fixing or a Dart 2 problem since Redux works with the Dart 2 SDK but not on Flutter with the Dart 2 SDK.
Hey @DrivEddy, @envious & @dodyg -- Just a heads up that I've released a new version of Redux 3.0.0 which addresses this problem. It also simplified the Redux API a bit, but requires a small migration. Please see the README for details: https://github.com/johnpryan/redux.dart/#redux-300-migration--dart-2-support
Hello,
after updating to dart 2. I get the following error when using
Reducer
My code looks like the following:
If I set the type to
dynamic
it works but I would prefer to not have to case the action.Any idea?