3 ms·
So imagine you have a class and you wan't to abstract away some stateful logic. You can use inheritance or mixins. You can use composition. You have to come up
by SebastianKra 5y ago
So imagine you have a class and you wan't to abstract away some stateful logic.
You can use inheritance or mixins. You can use composition. You have to come up with some solution for reactivity, which means setting up observers and disposables. You might have to set up some variables for storing the emissions from those streams.
I currently have to use an Angular-like framework, and my classes usually have 10-50 lines just setting up calls to other abstractions.
Hooks simplify that: setup, teardown, state and reactivity all in a single function call.
I'm not saying they're perfect, I would probably prefer a compiled solution like in Svelte. But when has anything ever been perfect.