Skip to content
Advertisement

Tag: svelte-3

Svelte’s reactivity with array operation

I’m studying svelte. the tutorial states that responsiveness is based on assignment and consequently operations with array such as array.push() must have an assignment. array.push() can be converted to numbers = […numbers, numbers.length + 1] . How to convert pop, shift, unshift, splice and other similar operation? Answer Unshift is the easiest, just use the reverse construction of the push

Svelte store function update

Svelte store documentation shows String or Integer being updated, but I did not find any dynamic function in store. I don’t understand how to make the getData function as a writable in order to notify the html of the change. In the following sample, I would like b to be shown after the updateKey function is called. You will find

Making class instance reactive in Svelte using stores

I am learning Svelte by creating simple app. The logic is written using classes. The idea is, that all the data needed comes from class instance properties. Instances should not be instantiated more than once. I am using stores to provide components this instances. The problem is I can’t get reactivity using this approach. I tried readable and writable stores

Advertisement