Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware creation failure does not throw error #178

Closed
elvisun opened this issue Apr 24, 2020 · 2 comments
Closed

Middleware creation failure does not throw error #178

elvisun opened this issue Apr 24, 2020 · 2 comments

Comments

@elvisun
Copy link

elvisun commented Apr 24, 2020

For the following code:

List<Middleware<AppState>> createMiddlewares() {
  final onFetchWishListMiddleware = _onFetchWishList();

  return [
    TypedMiddleware<AppState, FetchWishListAction>(onFetchWishListMiddleware),
  ];
}

Middleware<AppState> _onFetchSomething(SomethingService service) {
  return (Store<AppState> store, action, NextDispatcher next) async* {
    next(action);

    var user = selectors.getCurrentUser(store.state);

    service.list().listen((List<Something> items) {
      store.dispatch(FetchSomethingSuccessAction(items));
    });
  };
}

I accidentally put in async* which shouldn't be there, then this action's middleware and reducer wouldn't run, but it also didn't throw any error. Are we able to provide Middleware with a better type so we get warnings on things like this early?

@brianegan
Copy link
Owner

Hey there -- that's definitely a valid question, but would you mind opening this issue up on the redux.dat lib? https://github.com/johnpryan/redux.dart/issues

This library only hooks that library up to Flutter, and that's where the middleware is defined :)

@elvisun
Copy link
Author

elvisun commented Apr 24, 2020

sure thing, thanks Brian!
fluttercommunity/redux.dart#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants