Skip to content

Instantly share code, notes, and snippets.

@samstokes
Created June 30, 2011 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samstokes/1055502 to your computer and use it in GitHub Desktop.
Save samstokes/1055502 to your computer and use it in GitHub Desktop.
API example of AJAP responses
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
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