Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> fire this callback whenever this variable changes

Ouch, welcome to callback hell :(

Futures would be slightly better. The least painful approach to things like that. to my mind, is an explicit event loop, and posting events on a change.



Been there, helped design an entire embedded runtime based[1] around it, didn't mind it.

FWIW Eventing systems are not the same as callback hell. "Tell me when this variable changes" is the heart of a lot of really well engineered systems, including high performance hardware IO. (Fill this buffer w/o bothering the CPU, when the buffer is full, call this function to process its contents).

Eventing systems are nice.

> The least painful approach to things like that. to my mind, is an explicit event loop, and posting events on a change.

That is how Windows works under the covers.

Events are just syntactic sugar on top if that, in replacement of a giant switch/case statement.

[1]https://meanderingthoughts.hashnode.dev/cooperative-multitas...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: