michalweglarz.com
Frontend Engineer based in Oslo, Norway. Focused on modern web development. Gamer and tech enthusiast.
99 posts
121 followers
94 following
Regular Contributor
Active Commenter
comment in response to
post
That’s very cool! I also recently learned that importing a page file directly is useful in scenarios involving shallow routing, such as when rendering a different page inside the modal on the current page:
svelte.dev/docs/kit/sha...
comment in response to
post
Didn’t know that, thanks!
comment in response to
post
You can pass a $state object into context, whose properties will be reactive. You can then update those properties.
comment in response to
post
ah, the famous John Svelte
comment in response to
post
All we have left is to root for and support ladybird?
comment in response to
post
Oh didn’t know that. Thanks I’ll look it up
comment in response to
post
comment in response to
post
All told, it's been a year and a half of hard work to get to today. We've got so much to share about this project. Let us know what you'd like to hear about! :)
youtu.be/0mCsluv5FXA
comment in response to
post
does it work?
comment in response to
post
Not sure if that helps but there this open source library made with Svelte, TipTap and Shadcn: shad-editor.tsuzat.com
I haven’t used it but I see they have suggestions implemented.
comment in response to
post
Just stop
comment in response to
post
freaking ridiculous
comment in response to
post
Just used it for the first time. 😁Thanks!
comment in response to
post
Svelte has its preferences, obviously, but doesn’t force you into a complicated framework right away. It shows you alternatives in a fair and more balanced comparison and lets you build knowledge gradually.
comment in response to
post
Sorry, but it really reads differently to me. It says that if you don’t want to use a framework, you can build one yourself. But then, if you actually proceed, the docs keep reiterating that you really shouldn’t be doing that unless you’re an expert. There’s nothing in between, it seems.
comment in response to
post
Sure, it’s not easy, but you don’t always need a full-fledged framework to create web apps, especially if you’re just learning. The docs discourage you from trying the simplest possible way to start writing React. A way that is still viable today.
I don't think it's nitpicking.
comment in response to
post
If you go to the "Building a React Framework" page, as implied by the fragment, the very first thing you see is: "Building a framework is complex and requires extensive expertise across various domains."
It doesn't read the same as Svelte.
And a simple SPA doesn't count as "an unusual constraint".
comment in response to
post
Literally the next section in Svelte docs:
comment in response to
post
Usually when I finally get there I’m almost disappointed it’s already over 😅
comment in response to
post
"And I told them. “Big projects are small projects that someone kept working on for years and years.” Which apparently was an eye opener."
olafurw.com/2019-06-25-b...
comment in response to
post
I love the idea of a mechanical keyboard but I just can’t stand how annoyingly loud they usually are 😣
comment in response to
post
Copilot recently hallucinated a dependency array as the second argument to a Svelte $effect, and I was like nuh-uh buddy, you're free now
comment in response to
post
My example with dataToShow = $state() wasn't perfect, but I didn't exactly know how to convey the idea that the GeoMap component's updates exist outside of the Svelte reactivity system and therefore are not automatically reflected in the UI.
comment in response to
post
If you’re looking for something similar to Radix, you may wanna take a look at bits-ui and melt-ui. They provide “low-level” accessible primitives to built your components on. In fact, shadcn-svelte is based exactly on those libraries.
comment in response to
post
Thank you for helping me out! I feel like I understand effects much better now
comment in response to
post
That’s clever! A reactive proxy on top of a regular class. I think already found a solution but I’ll try to implement this later to see if this works.
comment in response to
post
As a matter of fact I just realized there’s indeed a callback ‘SourceAddedCallback’ that I could use to react to source initialization.
Btw it’s mapbox-gl I’m working with. I’m not super familiar with it yet
comment in response to
post
I am setting the source myself, just after map initialization in onMount.
If I do this:
geoMap = new GeoMap();
geoMap.addSource(…);
sourceAdded = true;
And then use sourceAdded in the effect, it works exactly as expected! No need for the snapshot anymore
comment in response to
post
In the actual code, the geoMap is already $state, but the real check looks like this:
$effect(() => {
const source = geoMap.getSource('source-id')
if (source?.type === 'geojson') {
source.setData(...)
}
}
comment in response to
post
I tried my best reproducing this in the repl and this is the closest I got: svelte.dev/playground/d... It’s not perfect because in this example it’s enough to declare `geoMap` in `App.svelte` as state, but it cannot be done in the real scenario as it is way more complex. Sorry if it got too messy.
comment in response to
post
I think that check is causing issues (I've seen docs mention conditions in effect), as non-reactive Map is undefined on the first run. As a workaround the snapshot solution forcefully triggers the effect to check the map object again, which is defined the second time around.
comment in response to
post
I think I made a mistake and the issue is different. I used an effect as I was trying to sync the state with an external non-reactive system. I have `Map` object instantiated in `onMount`, and when I want to update its field, I first need to check if it’s undefined before using `setData` method.
comment in response to
post
The code snippet I attached is just a vague excerpt from the larger thing, but when trying to reproduce it in the repl I realized you were absolutely right about 1. Accessing the properties inside the filter function is enough for it to be a dependency causing the effect’s re-run. TIL!
comment in response to
post
Yeah, I was paraphrasing the statement from the docs but lost its meaning while trying to shorten it. 😅 I’d like to avoid accessing the properties.
JSON.stringify could work but doesn’t seem much different from the snapshot.
Hm, that feature wouldn’t help me if I had the state in a context.