Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
A Model for Reasoning About JavaScript Promises [pdf] (franktip.org)
44 points by tegeek on Nov 10, 2017 | hide | past | favorite | 4 comments


Very thorough article, great to read through. I wrote simple promise implementation and explanation if anyone just starting out could use an introduction https://medium.com/gitconnected/understand-javascript-promis...


I'm seriously considering observables instead of promises in my next projects, because I have to mix promises with callbacks rather often and need to cancel actions.


Observables are pretty great when you have to coordinate a lot of async actions. The main downside is that they have their own learning curve - an article describing a Model for Reasoning about Observables would likely be much longer than the OP - so if you only have one or two async actions to deal with at a time, Promises will probably be simpler to implement and maintain


What is a good example of needing to cancel a promise besides the data fetch scenario? If any other type of async action takes long enough to run to be cancelled it would have to be in a worker thread (so it won't run in the UI thread) in which case you can post a message to stop the process (if it's async) or just remove the worker listener if the process is sync and let it finish. Maybe JS needs a way to kill a worker lol




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

Search: