That little $ prefix is telling Svelte to subscribe and unsubscribe appropriately. It's concise and declarative, but it isn't valid JavaScript; Svelte is a compiler. But it's worth it imo, because Angular's syntax is both verbose and imperative. Subscribing only breaks out of the reactive paradigm if you don't have another reactive paradigm on the other side. Svelte has synchronous reactivity built in.
It even works in callback functions. Here's another example:
This sounds amazing! Would you provide an example?
Thanks!
Angular
Svelte
That little
$
prefix is telling Svelte to subscribe and unsubscribe appropriately. It's concise and declarative, but it isn't valid JavaScript; Svelte is a compiler. But it's worth it imo, because Angular's syntax is both verbose and imperative. Subscribing only breaks out of the reactive paradigm if you don't have another reactive paradigm on the other side. Svelte has synchronous reactivity built in.It even works in callback functions. Here's another example:
Angular
(Or you could use
rxLet
and pass up the unwrapped value from the template into the callback function.)Svelte
You can play with a Svelte demo I made here
Updated Example with Signals
Angular
Svelte
Angular Callback
Svelte Callback