Comment

Comment by alskdjflaskjdhf

Probably the equivalent would be a custom store, something like this:

  <script>
    import { writable } from "svelte/store";
  
    function autoCounter(interval, initialValue = 0) {
      let { subscribe, update } = writable(initialValue);
      setInterval(() => update((n) => n + 1), interval);
      return { subscribe }
    }
  
    let counter = autoCounter(1000);
  </script>
  
  <div>The count is: {$counter}</div>

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton