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

[docs] refine load docs #7087

Closed
wants to merge 14 commits into from
Closed

[docs] refine load docs #7087

wants to merge 14 commits into from

Conversation

dummdidumm
Copy link
Member

  • split up the input properties into common, shared, server
  • docs for RequestEvent
  • code example for invalidation section
  • better separate locals section in handle docs
  • link back to load invalidation docs

Please don't delete this checklist! 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 and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

- split up the input properties into common, shared, server
- docs for RequestEvent
- code example for invalidation section
- better separate locals section in handle docs
- link back to load invalidation docs
@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2022

⚠️ No Changeset found

Latest commit: 47a1b8c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@theetrain theetrain left a comment

Choose a reason for hiding this comment

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

Thanks for streamlining the docs! Once I re-read the final copy, I'll get a feel for how a developer can learn about all the loading and invalidation logic in order to build pages with predictable re-loads.

documentation/docs/05-load.md Show resolved Hide resolved
documentation/docs/05-load.md Outdated Show resolved Hide resolved
documentation/docs/05-load.md Outdated Show resolved Hide resolved
packages/kit/types/ambient.d.ts Show resolved Hide resolved
@Rich-Harris
Copy link
Member

Docs are failing to deploy because the server-only load function doesn't yet include fetch. We could update the PR or (better) we could add fetch to RequestEvent

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
@dummdidumm
Copy link
Member Author

I went the "adjust the example" route - the fetch thing would be nice, but feels too unrelated to this PR.

@@ -264,6 +219,56 @@ Setting the same header multiple times (even in separate `load` functions) is an

You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](/docs/types#sveltejs-kit-cookies) API in a server-only `load` function instead.

### Shared-only inputs
Copy link
Member

Choose a reason for hiding this comment

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

The term "shared-only" was confusing to me, since I don't think we use this term to refer to +page.js/+layout.js loads anywhere else. Is there something more descriptive?

Copy link
Member

Choose a reason for hiding this comment

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

I like 'universal load' but 'universal inputs' sounds like it applies everywhere. Given that the only one is data I wonder if the better solution is to restructure this section slightly instead

documentation/docs/05-load.md Outdated Show resolved Hide resolved
packages/kit/types/ambient.d.ts Outdated Show resolved Hide resolved
packages/kit/types/index.d.ts Outdated Show resolved Hide resolved
Co-authored-by: Geoff Rich <4992896+geoffrich@users.noreply.github.com>
@dummdidumm
Copy link
Member Author

dummdidumm commented Oct 1, 2022

One thing I realized which may make it so hard to structure this right is that we maybe approach this wrong in the first place. Right now most of this section reads like API reference, mixed with some context and explanations around it. I think it would be better to move much of this into the API section in a slimmed down version. This section should instead be crafted around the task people want to achieve - getting data into the page, how and when to update that data, when to use shared vs server load functions. We can probably reuse what's there already but not centered around the API (i.e inputs and output) but rather the problems and solutions.

@Rich-Harris Rich-Harris mentioned this pull request Oct 3, 2022
5 tasks
@dummdidumm dummdidumm mentioned this pull request Oct 7, 2022
5 tasks
@dummdidumm
Copy link
Member Author

Created #7174 which "implements" my thoughts from the previous comment

@Rich-Harris
Copy link
Member

closed via #7174

@Rich-Harris Rich-Harris deleted the load-docs branch October 21, 2022 16:13
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.

4 participants