Hacker News new | ask | show | jobs
by judofyr 5760 days ago
In Rack you need to return a body which responds to #each (which yields strings); it doesn't need to return the body all at once:

    class Dummy
      def initialize(controller)
        @controller = controller
      end
      
      def each
        @controller.render.each { |part| yield part }
      end
    end
    
    @body = Dummy.new(self)
1 comments

Aaaah, and the work is done within #each and not within #call. I see. The only issue is if you have a middleware that modifies the output, because unless you're careful and/or you're doing something extremely minor near the start of the page, it'll all be processed in the middleware rather than the server. So the server still gets it all in one piece, and so does the client.