mojo
mojo copied to clipboard
Small introduction to promises
This is very similar to #1119, there is no real documentation in Mojo::Promise
. I think it would be nice to explain at the least the basics of how to use promises, their possible states, what returning promises in the ->then(...)
callbacks means and so on.
Somewhat related: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Synchronizing-non-blocking-operations talks about promises having the possible states pending
, fulfilled
or rejected
, but I was slightly confused not to find a way to check a promise for these states. I suspect I wouldn’t have wanted to try to do this in the first place, had I understood how best to use promises.
I'll try to provide a short introduction to promises with examples and open a pull request for further discussion soon.
I've started with the promise states. https://github.com/kraih/mojo/commit/8b3e17b3c7d6da776d67b5dfbece7ea3ae9790d4