Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imperative code in belongings-related components #23

Open
gabrc52 opened this issue Aug 29, 2023 · 0 comments
Open

Imperative code in belongings-related components #23

gabrc52 opened this issue Aug 29, 2023 · 0 comments

Comments

@gabrc52
Copy link
Collaborator

gabrc52 commented Aug 29, 2023

This is basically imperative code, leading to the sort of bugs that trying to write vanilla JS leads to:

I'd refactor this to use await blocks and take advantage of the fact Svelte lets you declare constants inside them (which was the reason I initially wrote the code like that, because I didn't know you could do that)

image

It's treating "loading" and "has error?" as two unrelated parts of state but they could be easily coupled with promises. Leading to this:

image

I think I'd already fixed a similar bug by changing some if statement but the advantage of writing declarative code is that you don't have to think about every branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant