0.0
No commit activity in last 3 years
No release in over 3 years
Every Batman.js app on Rails needs a sidekick. Bring realtime to the fight with Robin.js.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
>= 0
>= 0

Runtime

 Project Readme

Gem Version Dependency Status Code Climate Coverage Status Build Status

Robin.js on Rails

Every Batman.js app on Rails needs a sidekick. Bring realtime to the fight with Robin.js.

Usage

For client-side info on Robin.js, checkout the CoffeeScript source.

Vendoring

The latest version of the client-side Robin.js source is available through the asset pipeline under the robin namespace.

# app/assets/javascripts/application.js.coffee
#
#= require batman/es5-shim
#= require batman/batman
#= require batman/batman.rails
#= require batman/batman.jquery
#
#= require robin/robin

Make sure you load Robin after the Batman source files. To get things working on the frontend, checkout the setup details for Robin.js.

Realtime

The easiest way to get started is to add Robin to your Gemfile:

gem 'robin-rails' # Robin.js vendor and Rails events
gem 'faye' # websocket backend

For every model you want to update in realtime, include the Robin::Rails module.

class Post < ActiveRecord::Base
  include Robin::Rails
end

You can configure the Faye endpoint in an initializer.

# config/initializers/robin.rb
Robin.configure do |config|
  config.faye_url = 'http://localhost:9292/faye' # the default
end

That's it! Anytime a record is created, updated, or destroyed, the event will immediately be pushed to Robin.js subscribers via Faye. If you've got Faye running correctly (e.g. make sure you use Thin or another EventMachine friendly server), you should now be able to open several browser clients, edit models in the JS console, then watch the events propagate to other subscribed clients!

Contributing

This project is (obviously) in its infancy with just the basics. TODO lists a bunch of features I hope to get implemented, but this is GitHub: if you add a feature on your own, give me a hand and contribute!

No guidelines yet other than your basics: fork it, submit a pull request with relevant tests, and try to follow the conventions already in the code. Any and all quality contributions welcome!