DEV Community

Discussion on: Helpful patterns I use in Vue

Collapse
marktnoonan profile image
Mark Noonan

In terms of the loading and error states, it can sometimes get a bit clunky with all the booleans, and it’s nice to have a lookup for the single state that applies to something - eg, it can be in an error state, a loading state, a resolved state, whatever, but only one at a time. Then in your catch you change something like this.state.users from “loading” to “error” and otherwise from “loading” to “resolved”.

Love the others, especially the custom element idea. Kinda want to look into that. Thanks for sharing.

Collapse
jfbrennan profile image
Jordan Brennan Author

Ok that’s cool. I think…so you kind of define an enum of states 'error', 'loading', etc. and assign one to the things that are currently in that state? I like how that could work for stuff that kind of goes through a process of state changes loading —> error —> resolved, but I don’t think it works for granular errors like input validation of a large form.

Thanks for sharing!