Sha256: a6a7d07601e87f73baae65594674877a5b7aac5c5e625a6374ff1361c8741ea9
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
h1. EM-Promise !https://secure.travis-ci.org/cotag/em-promise.png! A promise / deferred implementation for EventMachine inspired by "AngularJS":http://docs.angularjs.org/api/ng.$q / "Kris Kowal's Q.":https://github.com/kriskowal/q From the perspective of dealing with error handling, deferred and promise apis are to asynchronous programing what try, catch and throw keywords are to synchronous programming. <pre><code class="ruby"> require 'rubygems' require 'em-promise' def asyncGreet(name) deferred = EM::Q.defer EM::Timer.new(5) do EM.defer do deferred.resolve("Hello #{name}") end end deferred.promise end EventMachine.run do asyncGreet('Robin Hood').then(proc { |greeting| p "Success: #{greeting}" }, proc { |reason| p "Failed: #{reason}" }) asyncGreet('The Dude').then do |greeting| p "Jeff '#{greeting}' Lebowski" end end </code></pre> h2. Start using it now # Read the "Documentation":http://rubydoc.info/gems/em-promise/EventMachine/Q # Then @gem install em-promise@
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
em-promise-1.1.1 | README.textile |
em-promise-1.1.0 | README.textile |