DEV Community

Discussion on: Synchronous State With React Hooks

Collapse
 
sirseanofloxley profile image
Sean Allin Newell • Edited

I think Vue's state pattern ia basically your custom hook but 'directly' on the trait; ie the getter/setter is how you access and set things in Vue. I think this is how that new hotness framework works... Uh... Hrmm.. svelte! That's the one. In vue (and knockout) i think there's a concept called a computed prop that is also similar to this problem. However, in knockout at least, it was limited such that you couldn't make cycles.

Could this also be solved by just making the validations also async?

Collapse
 
bytebodger profile image
Adam Nathaniel Davis • Edited

One of my previous approaches was making the validations async. That... worked. But I don't consider it to be ideal. Not that I have any problem with the concept of async/await, but it's kinda like a virus that spreads beyond its originally-intended borders, cuz await must be inside async. And once you make a function async, it returns a promise, that (depending upon your project and your inspections) either should or must be handled. Which too often leads to making the caller async, which in turn leads to the caller's caller being made async...

Before you know it, every dang function is async - which makes everything kinda messy for no good reason.

Collapse
 
sirseanofloxley profile image
Sean Allin Newell

Agreed.