summaryrefslogtreecommitdiff
path: root/examples/ssr/src/components/AddToCart.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ssr/src/components/AddToCart.svelte')
-rw-r--r--examples/ssr/src/components/AddToCart.svelte9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/ssr/src/components/AddToCart.svelte b/examples/ssr/src/components/AddToCart.svelte
index b03b8180a..0f7a97a93 100644
--- a/examples/ssr/src/components/AddToCart.svelte
+++ b/examples/ssr/src/components/AddToCart.svelte
@@ -1,11 +1,18 @@
<script>
+ import { addToUserCart } from '../api';
export let id = 0;
+ export let name = '';
- function addToCart() {
+ function notifyCartItem(id) {
window.dispatchEvent(new CustomEvent('add-to-cart', {
detail: id
}));
}
+
+ async function addToCart() {
+ await addToUserCart(id, name);
+ notifyCartItem(id);
+ }
</script>
<style>
button {