marcglasberg / async_redux

Flutter Package: A Redux version tailored for Flutter, which is easy to learn, to use, to test, and has no boilerplate. Allows for both sync and async reducers.
Other
230 stars 41 forks source link

The documentation for errorObserver doesn't appear to be correct #82

Closed simonckenyon closed 4 years ago

simonckenyon commented 4 years ago

If I define an errorObserver as per the documentation I get a compilation error:

The argument type 'bool Function(Object, ReduxAction, Store, Object, int)' can't be assigned to the parameter type 'ErrorObserver'.

marcglasberg commented 4 years ago

Yes, the docs were outdated. Thanks for noticing. It should be this:

var store = Store<AppState>(
  initialState: AppState.initialState(),
  errorObserver: MyErrorObserver<AppState>(),
);

class MyErrorObserver<St> implements ErrorObserver<St> {
  @override
  bool observe(Object error, StackTrace stackTrace, ReduxAction<St> action, Store store) {
    print("Error thrown during $action: $error");
    return true;
  }
}

Fix version: 2.12.3