Get back to lint clean
Allow integration by other fiber-sync implementations
Not ready once Fiber has started either
This is an implementation of promise.rb Promises for use with EventMachine.
Add this line to your application's Gemfile:
gem "em_promise.rb"
And then execute:
bundle
Or install it yourself as:
gem install em_promise.rb
A promise can be created from a plain ruby value, an EM::Deferrable, or another promise:
EMPromise.resolve(1)
EMPromise.resolve(EM_REDIS.get("key"))
You can also resolve a collection of promises, plain values, and EM::Deferrables:
EMPromise.all([
1,
EM_REDIS.get("key"),
some_promise
])
EM:Deferrable is also patched to support common Promise operations directly, or for conversion to a promise:
EM_REDIS.get("key").then { |x| EM_REDIS.get(x) }
EM_REDIS.get("key").promise
See also the docs for promise.rb since every EMPromise inherits from that gem's Promise class.
If you have any questions about this library, or wish to report a bug, please send email to: dev@singpolyma.net
If you have code or patches you wish to contribute, the maintainer's preferred mechanism is a git pull request. Push your changes to a git repository somewhere, for example:
git remote rename origin upstream
git remote add origin git@git.sr.ht:~yourname/em_promise.rb
git push -u origin master
Then generate the pull request:
git fetch upstream master
git request-pull -p upstream/master origin
And copy-paste the result into a plain-text email to: dev@singpolyma.net
You may alternately use a patch-based approach as described on https://git-send-email.io
Contributions follow an inbound=outbound model -- you (or your employer) keep all copyright on your patches, but agree to license them according to this project's COPYING file.