-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat(generator): export:route
hook and setPayload
#7422
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
|
||
// Shared payload | ||
this._payload = null | ||
this.setPayload = (payload) => { |
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.
Would getter/setter
for payload
make more sense here ?
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.
We may need something like a proxy then for deep watch. setPayload can ensure it is deep assigned and is simple :)
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.
This make me a little confused, we have this.setPayload
which is never called.
We also have another setPayload
as a scoped var
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 one set in the constructor is used by export:before
hook to set shared payload.
The one in scoped var is used for export:route
hook.
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.
Ah, I didn’t realize it’s passed by this.
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 I might have understood what’s happening here, so we have a global payload, each route has a scoped payload, what we’re doing is to make sure default value is always populated to updated payload.
Codecov Report
@@ Coverage Diff @@
## dev #7422 +/- ##
==========================================
+ Coverage 70.20% 70.26% +0.05%
==========================================
Files 88 88
Lines 3679 3696 +17
Branches 1007 1008 +1
==========================================
+ Hits 2583 2597 +14
- Misses 889 892 +3
Partials 207 207
Continue to review full report at Codecov.
|
Types of changes
Description
This PR allows providing a shared payload to all
nuxt export
routes similar to generate payloadThanks for @nilsnh (#6159 (comment)) for discovering this :)
Usage:
nuxt.config
pages/index.vue
It is also possible for modules using
export:route
to fill payload per route.Why using
setPayload
and not directly allow settingpayload
props?Current usage is checking
payload
is notnull
(default value) docs. So it changesnull
to object on first set.Checklist: