-
Notifications
You must be signed in to change notification settings - Fork 532
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
feat(middleware): accept partial methods #4673
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b566664:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense, but I remember that @francoischalifour originally wanted middlewares to not have optional keys. I wonder if this has changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense!
The original reason was that going from optional to required is a breaking change, while going the opposite isn't. Besides, I tend to avoid fully optional structures—now a middleware can be an empty object. |
→ makes sense
→ do we want to avoid it? |
That's not easy to answer. It'll add overhead to both our code and the middleware usage with conditional requirements. We have the same problem with the widget definition where nothing is required, but you still have to provide either |
This PR adds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally think with the "at least one", the downside of empty objects is alleviated, as well as it being instantiated with noops, so no new conditions need to be added. However we need to have a consensus on this as a team
What do you mean by "no new conditions"? |
conditions when using middleware, as it was needed in the initial version of the pr |
Summary
This PR allows middlewares to have partial methods. A middleware had to contain all of
subscribe, unsubscribe, onStateChange
methods, which isn't necessary.Result
It works the same as before except that the following is possible now: