Skip to content

How to use $effect with a non-Svelte object #14037

Answered by brunnerh
mitkury asked this question in Q&A
Discussion options

You must be logged in to vote

Sure.

Something similar to the observe/unobserve is often done with browser objects like MutationObserver/IntersectionObserver. Or you have an object like a MediaQueryList that dispatches events so you have addEventListener/removeEventListener.

(If the effect is not dependent on DOM state updates, you could switch to $effect.pre.)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mitkury
Comment options

@brunnerh
Comment options

Answer selected by mitkury
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants