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

add TypedMiddlewareBase abstraction #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dzziwny
Copy link

@dzziwny dzziwny commented Apr 23, 2022

Added typed middleware base abstraction, that allows to create a typed middleware as a simple class, like ex.

class MyMiddleware extends TypedMiddlewareBase<State, MyAction> {
  @override
  dynamic dispatch(Store<String> store, MyAction action, NextDispatcher next) {
    ...
  }
}

final store = new Store<State>(
  middleware: [MyMiddleware()],
);

Or TypedMiddlewareClass would be better, as there is already MiddlewareClass abstraction. Please leave a comment, do you see it useful. It's good if you prefer to keep project fully in OOP convention.

Otherwise, if you want to extend TypedMiddleware, you need to create something ugly like

class MyMiddleware<State, Action> extends TypedMiddleware<State, Action> {
  MyMiddleware()
      : super(
          (Store<State> store, Action action, NextDispatcher next) {
            ...
          },
        );
}

And within constructor it is no able to use other class properties.

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

Successfully merging this pull request may close these issues.

1 participant