Skip to content

Commit

Permalink
[docs] add docs for sequence (#2317)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 29, 2021
1 parent 704c7c7 commit c4a5bb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions documentation/docs/04-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export async function handle({ request, resolve }) {
}
```

You can add call multiple `handle` functions with [the `sequence` helper function](#modules-@sveltejs/kit/hooks).

This comment has been minimized.

Copy link
@Valexr

Valexr Aug 30, 2021

#modules-sveltejs-kit-hooks

This comment has been minimized.

Copy link
@ignatiusmb

ignatiusmb Aug 30, 2021

Member

Nice catch. Fixed in 5a49249, thanks!

This comment has been minimized.

Copy link
@Valexr

Valexr Aug 31, 2021

Just I’m translating to Russian πŸ€“


### handleError

If an error is thrown during rendering, this function will be called with the `error` and the `request` that caused it. This allows you to send data to an error tracking service, or to customise the formatting before printing the error to the console.
Expand Down
19 changes: 19 additions & 0 deletions documentation/docs/05-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,22 @@ import { build, files, timestamp } from '$service-worker';
- `build` is an array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`
- `files` is an array of URL strings representing the files in your `static` directory, or whatever directory is specified by [`config.kit.files.assets`](#configuration). You can exclude certain files from `static` directory using [`config.kit.serviceWorker.exclude`](#configuration)
- `timestamp` is the result of calling `Date.now()` at build time. It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches

### @sveltejs/kit/hooks

This modules provides a helper function to sequence multiple `handle` calls.

```js
import { sequence } from '@sveltejs/kit/hooks';

async function first({ request, resolve }) {
console.log('first');
return await resolve(request);
}
async function second({ request, resolve }) {
console.log('second');
return await resolve(request);
}

export const handle = sequence(first, second);
```

0 comments on commit c4a5bb1

Please sign in to comment.