DEV Community

DaniAcu
DaniAcu

Posted on

Svelte’s Growing Pains: Runes, Stores, and the Quest for Standards

I have this thought in my mind for a while. I don’t want to sound pretentious or anything. I just feel that the svelte development experience was ruined for my when runes start.

I know that stores are still a thing, and I can use it without issue. However more and more we are moving out of that.

Why I loved stores?

We have great articles talking about observables, and stores in svelte. Here some of that:

Stores are great to architecture a site and make sure that it works.

I work for more than a year in a Gigantic svelte project. The main problem I look was bad use of stores, why? Mentally shift was not happening. Everyone still thinking on values not observables.

We are building the UI, so when we are working of stores we need to think in everything as a observable. From user actions, to api calls everything.

Is really easy to do, identify where I need the value and just not touching despite that using it in a component that can be make thing tricky but clear ones you did it in every section.

It’s like using Rx in Nestjs. At the end, you can just return a observable in the controller, so everything can be an observable.

I know, we have cases where observable are pain to manage. However, still there we can insolate this cases with a particular solution and let the standard in the system. Making it easy to deal with in future.

The rule of dumb for observable is never manually subscribe except you are pretty sure what you are doing and that you will clean up that. Still there, thinking if you can skip it and have another alternative to not subscribe.

I also, start using stores as component state. I create kind of controller that just expose store and just manage it in the view. This makes looks pretty standard, inside the component and outside (globally) we end using same tool.

And one big thing was that in svelte, rxjs was compatible without a library. Observable was fist class citizen in svelte, thanks to stores. So when you are already working with observable, using rxjs is great because have everything you cloud need for that usage.

Runes, the problem of 0 standard

When runes comes, every standard in svelte was ruined. Let me be honest, this is not a runes or svelte thing. Is the problem inherit just for be backward compatible with a gigantic shift.

Kind of the same is happening today between signals and Observable in Angular. However, they are not trying to replace one with the another like svelte does with runes.

Their nothing of wrong with that. Just that we have a lot of libraries a community and a shift that is required for that. Yes, I know no lib need to be rewrite, but from people out of svelte community and trying to make his lib works inside svelte they will want to do it in latest version.

Products, Directors everyone want to be updated to latest version. Cloud be just a rule in some contract or a decision from a security team. Some high level management take tech decisions just looking tge first result in google. This is complicated the term of hace a standarized code, in a non standarized franework ecosystem

At some point, everyone will want to be updated to last version of svelte. From runes to attachments, including slots. However this will require have changes in codebases, despite open source.

I loved observable in svelte and I want to still using the framework, because it feel natural and simple. But it will require time to move to this new era, and surfing the waves of no standard in our codebases.

I know svelte team is doing great job surfing this wave and trying to be clear with our north.

What’s next

I want to still code in svelte, so I will try to start helping the community with 2 libraries that will help me and others to standarized their project.

Specially in terms of observables and service.

Here some of the project that I'm working on

Top comments (0)