ankurrsinghal / svelte-legos

A framework for Svelte Utilities 💡 Current status: 87 utilities.
https://svelte-legos.surge.sh
MIT License
804 stars 29 forks source link

Date store #102

Closed bobbymannino closed 1 year ago

bobbymannino commented 1 year ago

Having a date store would just save time in the case of needing a clock or something like that.

import { readable } from "svelte/store";

export const date = readable(new Date(), (set) => {
  const interval = setInterval(() => {
    set(new Date());
  });

  return () => clearInterval(interval);
});

Hopefully something like that would be useful

thank you

LeoCaprile commented 1 year ago

Feel free to submit a PR including this store and docs!!

ankurrsinghal commented 1 year ago

Handled