How to use Svelte store in .js file? ✨❓ Svelte Question Time ❓✨ “You have a Svelte question, I have an answer“ 😱😍 Introduction 00:00 Svelte store is a bless in a Svelte component, you can auto-subscribe store value using $-prefixed variable, which Svelte takes care of subscribing and unsubscribing the store for you. However, accessing store value outside of .svelte module may be a nightmare. Here are 2 of my advices to use store in a .js file. 1. derived() or get() 01:50 whenever you want to calculate something from a store, you need to decide whether the result is going to be a snapshot value of the calculation or you need a store that will keep calculating every time when the store used for the calculation has changed. This decides, whether to use get() to get the value at the point of time, in the former case, or use derived() to create a new store, in the latter case 2. subscribing inside the javascript file 10:24 If you keep needing to get the value of the store, you could subscribe the store an
Hide player controls
Hide resume playing