4 ms·
As the author states, ... Svelte Stores are rough. Beyond just missing usage patterns and documentation, we found that several features are lacking, especially
by hbbio 3y ago
As the author states, ... Svelte Stores are rough. Beyond just missing usage patterns and documentation, we found that several features are lacking, especially when used with native reactivity (`$:`). Another area lacking is TypeScript support.
Our frontend codebase at OKcontract is implemented with Svelte, but we had to build some low-level libraries (including a wholly new implementation of Stores) to make it worthwhile. We're very busy with our main launch now, but plan to open source these libs asap.
PS: We're not using SvelteKit
- tomgp 3y agostores are nice (i’ve found the transitions especially useful) but very much optional. i’ve used redux with svelte with good results and as the article says, it’s easy to get svelte to work with any pure js libraries
- pcthrowaway 3y agoI find this a bit confusing, because stores are one of Svelte's answers to react's state, and React's state is a hot mess once you go beyond component-local state
- hbbio 3y agoReact state is a hot mess, yes! We kept the same interface as the Svelte store, but with different semantics: - special management of undefined values - error management - promise management
- bavell 3y agoCurious - what makes react state a mess? Is it just that there's not much batteries included?
- pcthrowaway 3y agoBriefly speaking, it's because the mechanisms for dealing with complex state structures which are either global, or shared between multiple components which are not direct ancestors/ descendents of one another, are really complicated, due to how changes within that state need to be managed and propagated through the component dependency graph. Spend an hour, a day, or a year (depending on how broad you want your "introduction" to this topic to be) reading the various blogs and docs on state management systems if you want to see how crazy this gets.
- wildrhythms 3y agoCan you elaborate on lacking typescript support in stores? interface Book {...} export const selectedBook = writable<Book|null>(null); Works fine.
- hbbio 3y agoLacking TypeScript support is in addition to missing store features, sorry it was maybe not clear from my first sentence. Namely, unavoidable TS errors in the Svelte parts that require tricks mostly because the full TS syntax is not supported inside components.
- devbent 3y agoWhat is wrong with svelte stores? I've found them to be incredibly powerful and much easier than dealing with redux.
- Capricorn2481 3y agoThey are zustand/context with extra steps