MichaelMarner / dart-redux-remote-devtools

Remote Devtools for Dart & Flutter
https://pub.dartlang.org/packages/redux_remote_devtools
MIT License
52 stars 10 forks source link

Return dispatcher return values #22

Closed dennis-tra closed 4 years ago

dennis-tra commented 4 years ago

Hey,

unfortunately redux_thunk actions are not working as with the normal redux store. With the DevToolsStore I'm not able to write code that awaits the result of a thunk action:

await store.dispatch(MyThunkAction());

I have already created a PR for the upstream redux_dev_tools package.

However there needs to be a tiny change in this package as well.

I managed to get it working locally when all changes from both repositories are applied.

As soon as the upstream changes are merged I'll update the pubspec.yml of this package as well and change remove the "Draft" status of this PR.

EDIT: Now I'm wondering if this change here is only necessary because the RemoteDevToolsMiddleware is the first middleware in my chain. The second one is already the thunkmiddleware... 🤔

coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 112


Totals Coverage Status
Change from base Build 110: 0.0%
Covered Lines: 92
Relevant Lines: 100

💛 - Coveralls
MichaelMarner commented 4 years ago

Hey sorry for the delay getting to this. Thanks for the contribution! This looks good except should have a test case added to verify that the result of next is returned from call.

Perhaps modify the existing test case:

https://github.com/MichaelMarner/dart-redux-remote-devtools/blob/master/test/remote_devtools_middleware_test.dart#L165

To verify the returned value. Or make an additional test case.

MichaelMarner commented 4 years ago

But yes - this problem only exists because you don't have redux_thunks as the first middleware in your list. The Redux docs don't specify a requirement to return the result of calling next - and you are likely to run into problems with other middleware that also don't return values of calling next.

Essentially redux_thunk expects to be the first middleware.