Last active
July 28, 2019 03:20
-
-
Save hibuno/d36d0d88cbbdbae21c78f542c3e9c289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { | |
onMount, | |
tick, | |
beforeUpdate, | |
afterUpdate, | |
onDestroy | |
} from 'svelte' | |
let photos = [] | |
// Dijalankan setelah halaman di buat | |
onMount(async () => { | |
const res = await fetch('...') | |
photos = await res.json() | |
// Menunggu suatu proses yang belum selesai | |
await tick() | |
// do something here | |
}) | |
// Dijalankan ketika komponen akan di buat | |
beforeUpdate(() => { | |
// do something here | |
}) | |
// Dijalankan ketika komponen telah di buat dan di sync dengan data | |
afterUpdate(() => { | |
// do something here | |
}) | |
// Dijalankan setelah komponen di hapus dari halaman | |
onDestroy(() => { | |
photos = [] | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment