Replies: 2 comments
-
I agree 😀 Maybe an example how to use the MediaQuery class would make it a little bit more clear, at least to me :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yeah, would also agree with that. We have the following reactivity helper to update various places in the UI based on current time. To me it seems much simpler. export const now = new (class Now {
private subscribe: () => void = () => {};
constructor() {
this.subscribe = createSubscriber((update) => {
const intervalId = setInterval(update, 1000);
return () => {
clearInterval(intervalId);
};
});
}
get current(): number {
this.subscribe();
return Date.now();
}
})(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://svelte.dev/docs/svelte/svelte-reactivity#createSubscriber
It requires the knowledge of
window.matchMedia
andaddEventListener(window.matchMedia(), "change")
.A simpler example would be better
Beta Was this translation helpful? Give feedback.
All reactions