by hbbio · 3y ago · 0 comments
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
We kept the same interface as the Svelte store, but with different semantics:
- special management of undefined values
- error management
- promise managementSpend 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.
interface Book {...}
export const selectedBook = writable<Book|null>(null);
Works fine.
Namely, unavoidable TS errors in the Svelte parts that require tricks mostly because the full TS syntax is not supported inside components.