I’m not sure if I should be posting this here or adding to svelte creators github, but I have a problem here which may need a fix to be applied on the svelte side. I am trying to render a virtual list of images, by only having the images that are shown in the viewport, in the DOM. Here’s a
Tag: svelte-3
Import alias svelte component in typescript svelte
I want to import a svelte component in a typescript svelte component, it works for typescript file and other type of files, but in this case of svelte component, it resulted in a path error, here’s my code : It only works if i use ../../components/LoadingIcon.svelte instead of src/components/LoadingIcon.svelte Here’s the error: Uncaught (in promise) TypeError: Failed to resolve module
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
What is the difference between src, public, and build in folder structure?
I know what these files contain like build contains the minified file which is minified from src file. I need to know how browser works with it. I haven’t uploaded my build file to hosting service yet my website got rendered. In the website, <script> SRC was linked to build but there was no build uploaded but a build was
How to run server-sent events in svelte component in sapper
I have a svelte component named [symbol].svelte in which I want to initiate a connection to a streaming service to receive server-sent events. I’ve not found a way to do this successfully. Since EventSource only runs in the browser, I initialized it in the onMount function like so: This works fine, except when I navigate to another route that uses
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