starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | import { createSubscriber } from 'svelte/reactivity'; |
| 2 | |
| 3 | /** |
| 4 | * Wall clock that ticks once a second, but only while something reactive reads it |
| 5 | * (countdowns, ETAs). Outside an effect it is just Date.now(). |
| 6 | */ |
| 7 | const subscribe = createSubscriber((update) => { |
| 8 | const t = setInterval(update, 1000); |
| 9 | return () => clearInterval(t); |
| 10 | }); |
| 11 | |
| 12 | export function now(): number { |
| 13 | subscribe(); |
| 14 | return Date.now(); |
| 15 | } |