3 ms·
Can you say more about this? Your article says about `count += 1` that "we can do all this without the overhead and complexity of using proxies or accessors. I
by dfabulich 8y ago
Can you say more about this?
Your article says about `count += 1` that "we can do all this without the overhead and complexity of using proxies or accessors. It's just a variable."
But it's not just a variable; it's a magic variable that $$invalidates its contents. I'd be much happier to write `state.count += 1` and allow my debugger to step into the proxy in dev mode, but then have the production compiler convert the proxy into a direct call to $$invalidate to minimize runtime overhead and support legacy non-proxy browsers.
- rich_harris 8y agoFirstly, that's more code you're having to write (and object property names don't typically get mangled, so you'll end up shipping more code as well as writing more code). Write less code! https://svelte.dev/blog/write-less-code https://svelte.dev/blog/write-less-code You can easily debug reactive variables, either using the `{@debug ...}` tag in the template (https://svelte.dev/examples#debug https://svelte.dev/examples#debug) or by using `debugger` in your script tag (https://svelte.dev/repl?version=3.0.0&gist=adc35e969343aad6026c7dd3836aa426 https://svelte.dev/repl?version=3.0.0&gist=adc35e969343aad60...).