{"id":21656985,"url":"https://github.com/cotag/em-promise","last_synced_at":"2025-04-11T22:12:41.635Z","repository":{"id":59153581,"uuid":"6304066","full_name":"cotag/em-promise","owner":"cotag","description":"A promise/deferred implementation for EventMachine","archived":false,"fork":false,"pushed_at":"2013-03-21T00:27:57.000Z","size":167,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T22:12:37.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cotag.png","metadata":{"files":{"readme":"README.textile","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-20T01:18:25.000Z","updated_at":"2022-04-22T13:40:52.000Z","dependencies_parsed_at":"2022-09-13T17:50:41.993Z","dependency_job_id":null,"html_url":"https://github.com/cotag/em-promise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fem-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fem-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fem-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotag%2Fem-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cotag","download_url":"https://codeload.github.com/cotag/em-promise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487683,"owners_count":21112190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T09:18:37.581Z","updated_at":"2025-04-11T22:12:41.589Z","avatar_url":"https://github.com/cotag.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"h1. EM-Promise\r\n\r\n!https://secure.travis-ci.org/cotag/em-promise.png(Build Status)!:https://travis-ci.org/cotag/em-promise\r\n\r\nA promise / deferred implementation for EventMachine inspired by \"AngularJS\":http://docs.angularjs.org/api/ng.$q / \"Kris Kowal's Q.\":https://github.com/kriskowal/q\r\n\r\nFrom 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.\r\n\r\n\u003cpre\u003e\u003ccode class=\"ruby\"\u003e\r\nrequire 'rubygems'\r\nrequire 'em-promise'\r\n\r\ndef asyncGreet(name)\r\n\tdeferred = EM::Q.defer\r\n\t\r\n\tEM::Timer.new(5) do\r\n\t\tEM.defer do\r\n\t\t\tdeferred.resolve(\"Hello #{name}\")\r\n\t\tend\r\n\tend\r\n\t\r\n\tdeferred.promise\r\nend\r\n\r\n\r\nEventMachine.run do\r\n\r\n\tasyncGreet('Robin Hood').then(proc { |greeting|\r\n\t\tp \"Success: #{greeting}\"\r\n\t}, proc { |reason|\r\n\t\tp \"Failed: #{reason}\"\r\n\t})\r\n\t\r\n\tasyncGreet('The Dude').then do |greeting|\r\n\t\tp \"Jeff '#{greeting}' Lebowski\"\r\n\tend\r\n\t\r\nend\r\n\r\n\u003c/code\u003e\u003c/pre\u003e\r\n\r\n\r\nh2. Start using it now\r\n\r\n# Read the \"Documentation\":http://rubydoc.info/gems/em-promise/EventMachine/Q\r\n# Then @gem install em-promise@\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcotag%2Fem-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcotag%2Fem-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcotag%2Fem-promise/lists"}