A light browser push framework that provides listeners on web clients and publishers on Rails servers. If you can keep all your business logic on the server and maintain a dumb client, life is serene. If you can do that while offering a live, interactive page with real-time updates, you're a rock star.
<div <%= listener_attrs(@transaction,:grand_total) %>>
</div>
ForeignOffice.publish(
channel: "Transaction#{@transaction.id}",
object: {grand_total: @transaction.grand_total})
After you publish, your div will show the latest grand total via browser-push. Your server can update your client on demand!
See here for all the ui actions you can trigger when you receive a message.
In your gemfile:
gem 'foreign_office'
ForeignOffice.config(
bus: {
klass: ForeignOffice::Busses::PusherBus,
app_id: <YOUR PUSHER APP ID>,
key: <YOUR PUSHER KEY>,
secret: <YOUR PUSHER SECRET>
})
//= require foreign_office
foreign_office.config({
bus_name: 'PusherBus',
key: '<YOUR PUSHER KEY>'
});
If you'd rather use Pubnub, see here.
If you'd like to wrap each publish request so you can background it or instrument it, then see here.
Send us your ideas. Better yet, send us a pull request on github!
Along with Eric Draut (@edraut), Adam Bialek (@abialek) and Matt Leonard (@mattleonard) are core contributors.