🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

rails-async

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails-async

0.1.1
Rubygems
Version published
Maintainers
1
Created
Source

A Rails engine that provides a view helper that will speed your page loads. See the bottom of the README for the example use, that will probably make more sense than me explaining it here.

This is Alpha, naive, itch scratching bozo code.

Don't reinvent the wheel. Always reinvent the wheel.

Ponder this, good luck.

Install

Add it to your gemfile:

gem "rails-async", :require => "async"

Setup

Add the following to your app/controllers/application\_controller.rb:

class ApplicationController < ActionController::Base
  helper :async
  after_filter do
    Thread.new { AsyncCache.instance.build }
  end

  # ...
end

That's it. If you don't want it available on every request, add it to the specific controllers where you intend to use it.

Use

Slow page:

<h1>Accounts</h1>
<ul>
  <% sleep 3.8 %>
  <% @accounts.each do |account| %>
    <li>
      <%= render 'account', :account => account %>
    </li>
  <% end %>
</ul>

Fast page:

<h1>Accounts</h1>
<ul>
  <% asynchronously do %>
    <% sleep 3.8 %>
    <% @accounts.each do |account| %>
      <li>
        <%= render 'account', :account => account %>
      </li>
    <% end %>
  <% end %>
</ul>

Async worries about responding, you worry about why your code is so slow.

Unanswered Questions

Speed: at what point is an approach like this worse than just rendering the whole page at once? Gotta measure to know if you're improved anything.

Practicality of testing: what's the mimimum viable test rig?

Praticality in general: who's gonna use it? When would this be more useful than manual ajax / async page splitting?

FAQs

Package last updated on 04 Nov 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts