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
import { readable, derived } from 'svelte/store'; | |
export const time = readable(new Date(), function start(set) { | |
const interval = setInterval(() => { | |
set(new Date()); | |
}, 1000); | |
return function stop() { | |
clearInterval(interval); | |
}; |
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
import { readable } from 'svelte/store'; | |
export const time = readable(new Date(), function start(set) { | |
const interval = setInterval(() => { | |
set(new Date()); | |
}, 1000); | |
return function stop() { | |
clearInterval(interval); | |
}; |
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 { count } from "./stores.js"; | |
</script> | |
<h1>The count is {$count}</h1> |
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 { onDestroy } from "svelte"; | |
import { count } from "./stores.js"; | |
let countValue; | |
const unsubscribe = count.subscribe((value) => { | |
countValue = value; | |
}); |
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
import { writable } from 'svelte/store'; | |
export const count = writable(0); |
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
{#if visible} | |
<p transition:fade> | |
Fades in and out | |
</p> | |
{/if} |
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
<style> | |
.container { | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
} | |
</style> |
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
render(){ | |
return ( | |
<ul> | |
{this.state.cats.map(cat => ( | |
<li> | |
<a target="_blank" href={`https://www.youtube.com/watch?v=${cat.id}`}> | |
{cat.name} | |
</a> | |
</li> | |
))} |
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
<ul> | |
{#each cats as { id, name }, i} | |
<li> | |
<a target="_blank" href="https://www.youtube.com/watch?v={id}"> | |
{i + 1}: {name} | |
</a> | |
</li> | |
{/each} | |
</ul> |
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
render(){ | |
let component; | |
if (loading) { | |
component = <LoadingIndicator /> | |
} else { | |
component = <SomeOtherComponent /> | |
} | |
return ( | |
<div> |
NewerOlder