From 258214cc6840ad8fce4a46f3c339ec8002a329ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20=C3=85berg=20Kultalahti?= Date: Wed, 15 Jan 2020 20:30:44 +0100 Subject: [PATCH 1/5] adds an example to the goto documentation --- site/content/docs/03-client-api.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/site/content/docs/03-client-api.md b/site/content/docs/03-client-api.md index 385bd6cc6..5e3e9f02a 100644 --- a/site/content/docs/03-client-api.md +++ b/site/content/docs/03-client-api.md @@ -33,6 +33,20 @@ Programmatically navigates to the given `href`. If the destination is a Sapper r Returns a `Promise` that resolves when the navigation is complete. +```html + +``` + ### prefetch(href) From 610b624fc02e290d78e62725209017c65d689af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20=C3=85berg=20Kultalahti?= Date: Wed, 15 Jan 2020 20:32:16 +0100 Subject: [PATCH 2/5] change highlighting to JS and adds missing char. --- site/content/docs/03-client-api.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/site/content/docs/03-client-api.md b/site/content/docs/03-client-api.md index 5e3e9f02a..c551a5e7b 100644 --- a/site/content/docs/03-client-api.md +++ b/site/content/docs/03-client-api.md @@ -33,18 +33,17 @@ Programmatically navigates to the given `href`. If the destination is a Sapper r Returns a `Promise` that resolves when the navigation is complete. -```html - +const saveItem = () => { +... +} ``` From c4543b50e16bedce263eb9b2c2507bf1eaa7536d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20=C3=85berg=20Kultalahti?= Date: Wed, 15 Jan 2020 20:33:14 +0100 Subject: [PATCH 3/5] another missing character --- site/content/docs/03-client-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/docs/03-client-api.md b/site/content/docs/03-client-api.md index c551a5e7b..be55a945f 100644 --- a/site/content/docs/03-client-api.md +++ b/site/content/docs/03-client-api.md @@ -38,7 +38,7 @@ import { goto } from '@sapper/app const navigateAndSave = () => { goto('/'); - saveItem() + saveItem(); } const saveItem = () => { From fe67637cb76734515817de69f5bf2cf5681200de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20=C3=85berg=20Kultalahti?= Date: Sat, 25 Jan 2020 12:04:13 +0100 Subject: [PATCH 4/5] Some documentation on goto promise Updates example to show how to use async promise functionality. --- site/content/docs/03-client-api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/content/docs/03-client-api.md b/site/content/docs/03-client-api.md index be55a945f..7ac7e691a 100644 --- a/site/content/docs/03-client-api.md +++ b/site/content/docs/03-client-api.md @@ -31,18 +31,18 @@ sapper.start({ Programmatically navigates to the given `href`. If the destination is a Sapper route, Sapper will handle the navigation, otherwise the page will be reloaded with the new `href`. In other words, the behaviour is as though the user clicked on a link with this `href`. -Returns a `Promise` that resolves when the navigation is complete. +Returns a `Promise` that resolves when the navigation is complete. This can be used to perform actions once the navigation has completed, such as updating a database, store, etc. ```js import { goto } from '@sapper/app -const navigateAndSave = () => { - goto('/'); +const navigateAndSave = async () => { + await goto('/'); saveItem(); } const saveItem = () => { -... + // update a database/store, etc. } ``` From c2dc8dbf3616c782cb8dfc22e7a9d0aa67128770 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 25 Feb 2020 21:27:41 -0500 Subject: [PATCH 5/5] tweak --- site/content/docs/03-client-api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/content/docs/03-client-api.md b/site/content/docs/03-client-api.md index 7ac7e691a..686708d99 100644 --- a/site/content/docs/03-client-api.md +++ b/site/content/docs/03-client-api.md @@ -34,15 +34,15 @@ Programmatically navigates to the given `href`. If the destination is a Sapper r Returns a `Promise` that resolves when the navigation is complete. This can be used to perform actions once the navigation has completed, such as updating a database, store, etc. ```js -import { goto } from '@sapper/app +import { goto } from '@sapper/app'; const navigateAndSave = async () => { await goto('/'); saveItem(); } - + const saveItem = () => { - // update a database/store, etc. + // do something with the database } ```