I don't understand this. I am trying to subscribe to a svelte store. But the closure function which is being passed to subscribe is being immediately invoked. Even though the value of the store hasn't changed.
with the following code:
<script>
import { onDestroy } from 'svelte';
import { writable } from 'svelte/store';
const store = writable({ givenName: '', familyName: '' });
const unsubscribe = store.subscribe( state => {
console.log('This function shouldn\'t have been invoked on subscription.');
});
onDestroy(unsubscribe);
</script>
<h1>
Please check the console output ...
</h1>
IMHO, the closure function should be fired on change and not on subscriptionn or is there something I am missing?