3 ms·
Unlike a Promise, I hope you can cancel processes in Elixir
by toastal 7y ago
Unlike a Promise, I hope you can cancel processes in Elixir
- jhgg 7y agoYou can kill them. Just like processes on your computer!
- capableweb 7y agoYou can cancel a Promise by using AbortController and its AbortSignal, still experimental but supported in most browsers already.
- toastal 7y agoI'll stick to Futures for; Futures work everywhere now and aren't immediately invoked when called with new.
- capableweb 7y agoNot sure exactly what futures you're referring to as there are no "native" futures in any browser (that I know of) so they are either implemented on top of Promises or by using callbacks, and still doesn't solve the problem of cancellation...
- toastal 7y agoYou're right. There's not a native solution. I've used Fluture (https://github.com/fluture-js/Fluture https://github.com/fluture-js/Fluture) for while now as it follows the Fantasy Land spec. The canceler is returned in the Future's constructor. The biggest feature difference in comparison to Promises is that you can pass around a Future adding to the data transformation without it being invoked until fork is called. It's good to know that there exists a way to do this natively now though.