-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Rename handle
's render
parameter to resolve
#1566
Conversation
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.
It runs on both pages and endpoints, so it describes the action better than render
I dunno, |
@benmccann suggested in discord that we change the signature to export function respond({ request, handle }) {
return handle(request);
} I think calling the hook itself |
How about |
Those are all do-something verbs! They suggest that the function has an effect, rather than returning a value. A get-something verb is something like |
Maybe this is too far outside the box and I'm just not correctly conceptualizing the dataflow here, but Hooks in general really feel more like middleware to me than anything. Data flow is:
As in, data flows into your application, through your hooks, and down to your loads/endpoints, which then (in the case of endpoints), respond to requests. The way I think about it, when I make a request to an endpoint from a If that's correct, the language around the hooks would make more sense if it sounded like a middleman: export function handle({ request, continue }) {
return continue(request);
}
// or
export function handle({ request, forward }) {
return forward(request);
} I think that may shift the question to what |
What about |
Or
Adding 'er' will make it more clear. We are returning response handled by a handler. Or we are returning response rendered by a renderer. |
I think the Likewise, With that in mind, thoughts on the name export async function intercept({ request, handler }) {
request.locals.user = await getUserInformation(request.headers.cookie);
const response = await handler(request);
return {
...response,
headers: {
...response.headers,
'x-custom-header': 'potato'
}
};
} The idea of Renaming |
That's a nice reference, I like the idea of Still conflicted on the |
How do you feel about EDIT: I take it back, if this runs on the server, that might shadow the process variable if someone does |
Personally, I also like the idea of export function intercept({ request, forward }) {
return forward(request);
// or return continue(request);
} I'm flipflopping a bit on which I like better, but I think "continue" probably makes the most sense in my head. |
I'm not so keen on |
Please keep in mind of ES reserved keywords, words like |
After discussion with the other maintainers, I will rename to
|
handle
's render
parameter to respond
handle
's render
parameter to resolve
remove reference to 'renderer', which is confusing now that we no longer use `render`
…r/cutomExtensionTest * 'master' of https://github.com/sveltejs/kit: fix: append trailing slash in manifest (sveltejs#1507) Version Packages (next) (sveltejs#1590) Rename `handle`'s `render` parameter to `resolve` (sveltejs#1566) Replace favicon (sveltejs#1589)
I was a bit confused by the name
render
because it had a heavy page connotation in my mind (another user stated the same), so I wasn't sure if you'd be calling it for endpoints as well. Rich had suggestedrespond
could be a more neutral alternative. I like that name, so wanted to raise the question of renaming it here