Zed A. Shaw, Writer Profile picture
Jun 2, 2021 10 tweets 4 min read Read on X
I have a couple of new gotchas for people doing Svelte:

1. fade:out, or almost any "out" transition effect is death. Avoid at all costs.

2. {#await} on a promise is great, but if you update the promise it reloads the *entire* DOM at that point. Put it into a component.
For #1, the demo involves this fade:out on the Spinner I use to show the video is loading. Seems harmless *until* you want to transition to an entire new page/component, say with svelte-spa-router.
You can see it happen here. I click the link for a related video, and you can see the current video has to "fade out", preventing that page from leaving the DOM, so it looks like both pages load at the same time. I'm at a point now where I don't use *any* out transitions.
Once you remove the fade:out from everything it works flawlessly. I consider this a bug, just not sure where. I think Svelte needs a way to say "stop all transitions NAO!" so svelte-spa-router can use it.
For #2 the demo is in how, when I click on a related video it looks like the *entire* list of videos is first reset to an empty array, then filled. This causes the whole DOM tree at that point to go away, flash, then come back. What's supposed to happen is it should diff the DOM.
The cause is this little svelte-spa-router hack on lines 10-12 that I needed in a page to make links work as expected. For bizarre reasons svelte-spa-router only considers links to *different* route components as a new link, so it doesn't run onMount. Those lines fix it.
BUT, this is not a svelte-spa-router page that I've put into client/routes.js. It is a separate component that I'm using *inside* those routes anywhere I need related videos. That means these lines aren't needed, and are just causing extra DOM work. Remove them and it's fixed.
See how now the list of related videos doesn't flash, go away come back, or reload images? Look at the top right and you can see how, when I pick a video from a new series, *those* videos do change though. That's the correct behavior.
There ya go. If you have a situation where it looks like one component is sticking around after another has loaded, look for out transitions. They hold things up.

If you have aggressive DOM tree replacement, look for over using $: and await/promises, and remove them.
Finally, I find a lot of problems go away when you move things into components. It seems like Svelte is better at working the DOM when the DOM is composed of a few big components rather than one giant page. What I do is make the page so it looks right, then break it up.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Zed A. Shaw, Writer

Zed A. Shaw, Writer Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @lzsthw

Jun 4, 2023
People who write in a pompous "King James" style sound pretentious. This article on teaching completely loses the message because the author is trying to sound "official" by sounding "biblical". It then slides downhill from there as expected:

intellectualmathematics.com/manifesto/
Clearly the author has never been poor, taught or studied in a poor school, never gone hungry, and has probably only taught people who would fit this model of "perfect". Slap all the "therefore" you want, the entire premise is disconnected from reality. Image
This is not supported by any research, and this is typically used to justify excluding people who don't already know a topic by claiming that a student is forever unteachable because they couldn't "handle" the artificial challenge. You mostly find this attitude in gifted kids who… twitter.com/i/web/status/1… Image
Read 7 tweets
Jun 2, 2023
A thread of weird Youtube searches for when you want some soothing noise to code to. Most of these either have no talking, or if there is talking it's low whispers (because some folks like that). All of these are also Safe for Work in most places.

Here's my favorites:
1. "dugout"

It's almost always a Russian man or woman building a little house in the dirt. They don't talk much, usually there's a dog they talk to but otherwise, woods, rain, fires, cooking, and digging.

youtube.com/results?search…
2. "camping rain"

Similar to "dugout" but this is all over the world, with the best ones in Korea and Australia. A little more talking but not a lot of digging sounds and mostly just rain and cooking.

youtube.com/results?search…
Read 7 tweets
Dec 19, 2022
Another thought I had recently was that I would _like_ to actually buy a product from many open source projects. No, I don't want to donate, I want to pay you for a real product, so I'm your customer and you try to make me happy.

But they always screw this up in weird ways:
1. No, I don't want to buy you coffee, or "donate" because that's a dodge to avoid the obligation of treating me like a customer. FLOSS projects do this so they can get money, and then force any changes they want on your without your consent crying "ENTITLED" when you complain.
2. On average I pay say $10-$30 for a video game, and those are way more expensive to produce than most open source projects. That's a reasonable price point for a lot of things like gitea, but what do they do?

Target the ENTERPRISE market with "Call us for pricing!"
Read 9 tweets
Dec 19, 2022
So, Gitea created some kind of corporation to try to make money on Gitea, and apparently that's caused a fork:

blog.codeberg.org/codeberg-launc…

The comments are amazingly hypocritical given that...

Gitea is written in Go, which is famously run with an iron fist by Google.
The hypocrisy is simply amazing. If all of these people are so against corporate open source then why the hell are they also all using Go or anything by Google?

Because, if you're a Trillionaire then people are grateful for your table scraps and ignore their supposed "morals".
Google has:

1. Unilaterally pushed a packaging system they wanted without any community input.
2. Banned people randomly for criticizing the project.
3. Let a single engineer on Chrome decide the entire fate of gRPC on the internet.

Not a peep from the FLOSS tryhards.
Read 4 tweets
Dec 16, 2022
My jsdoc replacement is at a point where I can browse my own documentation:

git.learnjsthehardway.com/learn-javascri…

with a simple viewer at:

git.learnjsthehardway.com/learn-javascri…

Now I need to process the docs comment and either I support the JSDoc format--which irritates me--or simplify it. Image
My problem with the JSDoc format is it's just a copy of the JavaDoc format, and it's far too strict, which is a Java thing. I'd rather have it tone down the format's requirements and handle more looseness, which would make documentation easier.
But, the JSDoc/JavaDoc format does make a ton of sense in many ways. Since I'm actually parsing the file it _could_ eventually make guesses at return values, and at least show the value of default asigned parameters, but not much more without big code work.
Read 4 tweets
Nov 8, 2022
I found it! It was in a Svelte transitions module that comes with Svelete, but...I think Microsoft is adding this copyright to all source that's compiled with TypeScript? I'm pretty damn sure that's not how copyright works, especially for programming languages.
So the exact file is this one:

github.com/sveltejs/svelt…

There's no Copyright notice in that source .ts file, but this is what's in the generated .mjs file:
That confirms it then, Microsoft is plastering their Copyright on _your_ code when you use TypeScript. That's absolutely not correct, both morally and according to the law. Can you imagine if Adobe Premiere inserted a (c) Adobe on all movies you edited?
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(