-
Notifications
You must be signed in to change notification settings - Fork 433
Add registerHooks method to Component decorator #46
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
Conversation
} | ||
|
||
const Component: ComponentDecorator = function <V extends VueClass>( | ||
options: Vue.ComponentOptions<any> | V |
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.
Can we replace any
with Vue
?
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.
👍 fixed.
if (typeof options === 'function') { | ||
return componentFactory(options) | ||
} | ||
return function (Component: V) { | ||
return componentFactory(Component, options) | ||
} | ||
} as any |
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 would suggest to use namespace
trick to bypass type assertion. Here is an example https://github.com/HerringtonDarkholme/av-ts/blob/master/src/core.ts#L173
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.
Oh, it's nice trick, thanks!
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.
The implementation looks good to me 😄
Any other comments? |
LGTM 👍 |
This feature allows us to register additional hooks for class components like Vue Router's
beforeRouteEnter
.Close #38