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

switch handle hook from positional arguments to named arguments #959

Merged
merged 7 commits into from
Apr 12, 2021

Conversation

Conduitry
Copy link
Member

This resolves #958 by switching the handle hook from positional arguments to named arguments. It also updates the appropriate tests and documentation.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts

});

const hooks = get_hooks(user_hooks);
const hooks = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_hooks seemed to be an unnecessary indirection, and I've removed it while updating this.

@dummdidumm
Copy link
Member

dummdidumm commented Apr 10, 2021

Is there any way to make this more obvious to existing users, like print an error telling you that the contract changed if someone upgrades and uses the old contract? That could be removed later on.

@Conduitry
Copy link
Member Author

Maybe in dev mode we could check hooks.handle.length? I'm not sure where would be the best place and mechanism to surface this warning though.

@Conduitry
Copy link
Member Author

@pngwn mentioned in chat that adding more specific errors or warnings around breaking changes in beta would be unmanageable. I don't disagree with this. In beta, I don't feel much guilt about changing the API like this if it's an improvement, and at this stage I also don't foresee that terribly many issues being opened which we would then have to close and say 'read the changelog'.

Rich-Harris and others added 2 commits April 11, 2021 20:43
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
documentation/docs/04-hooks.md Outdated Show resolved Hide resolved
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
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.

handle hook should accept { request, render } rather than positional parameters
4 participants