Skip to content

Instantly share code, notes, and snippets.

@seamusabshere
Created October 5, 2009 19:46
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 seamusabshere/202376 to your computer and use it in GitHub Desktop.
Save seamusabshere/202376 to your computer and use it in GitHub Desktop.
class FriendsController
def index
@friends = @user.friends
@friends_of_friends = slow { @user.friends_of_friends }
end
def import
@result = slow { @user.friends.import(params[:big_csv]) }
end
end
# (app/views/friends/index.html.erb)
# Your friends are <%= @friends %>
# The friends of your friends are <%= friends_of_friends %>
# (app/views/friends/import.html.erb)
# You imported <%= @result %>
# implementation idea
# @result = slow { sleep(900); "hello" } would return like a SlowString
# t0: <%= @result %> => <span class="processing" id="slow_string_020d92ojaodisjdad">processing...</span>
# t1: <%= @result %> => ditto
# ...
# t900: <%= @result %> => <span class="done" id="slow_string_020d92ojaodisjdad">hello</span>
#
# and there would be baked-in javascript that observed these slow strings until AJAX calls
# on them returned 200 or smth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment