Referencing a variable with a $ prefix should cause code similar to the following to be added:
import { onDestroy } from 'svelte';
let $foo;
onDestroy(foo.subscribe($$value => {
$foo = $$value;
});
(See RFC 2 for an explanation.)
In dev mode, it should probably check that foo has a subscribe method first, and print a more helpful error.
Questions:
foo is not defined, what do we do? Assume $foo isn't the unwrapped value of a store?$foo is already defined by the user, do we still add this code?If
foois not defined, what do we do?
I vote for "throw a noisy error".
If
$foois already defined by the user, do we still add this code?
I vote for "throw a noisy error".
closed via #1880
Most helpful comment
I vote for "throw a noisy error".
I vote for "throw a noisy error".