Created
June 30, 2011 02:31
-
-
Save samstokes/1055502 to your computer and use it in GitHub Desktop.
API example of AJAP responses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomethingController | |
include AjapController | |
defer_response :only => :slow_operation | |
def slow_operation | |
later do |ajap| | |
Leviathan.do_something_very_slowly.callback do |result| | |
ajap.respond :status => 200, :message => result | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Workers::SomethingElse | |
def handle_message(message) | |
Ajap.later(message['pusher_channel'], message['ajap_event_id']) do |ajap| | |
Leviathan.do_something_else_very_slowly.callback do |result| | |
ajap.respond :status => 200, :message => result | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment