brianegan / redux_thunk

Redux Middleware for handling functions as actions
MIT License
88 stars 8 forks source link

Result of Thunk not being returned from dispatch #17

Closed fuzing closed 3 years ago

fuzing commented 3 years ago

Greetings and thank you for your work on this package.......

I was under the impression that dispatching a thunk action would return the value from the thunk, but I'm consistently receiving null.

e.g.

ThunkAction<AppState> someAction() {
    Future<void> abc(Store<AppState> store) async {
        await Future.delayed(Duration(seconds: 1));
        store.dispatch(OtherAction());
    };
    return abc;
}

var v = store.dispatch(someAction());
print(v);       // expecting v to be a Future<void>, but it's null instead
await v;       // awaiting null is a noop - never has intended effect

Am I incorrect here, or doing something wrong?

Thank you!

fuzing commented 3 years ago

Problem lay with another middleware that was not returning the value from its call to next()

Thank you