0

I'm implementing Notifications in an Angular app that will get the data from a Rails API. I've been thinking about using the Angular Poller module in a polling technique, however I was wondering if there's a better way where you can push the data from the Rails API to Angular whenever there is an update?

1
  • There is - webSockets. Have a read here: fenixapps.com/blog/nodejs-angularjs-and-socket-io. Unlike polling, web sockets gives real live-data integration. However it needs much more work to be done. Currently Rails does not support sockets unfortunately, but it is to be supported in Rails 5 - and those are to be released very soon (fall 2015). Commented Sep 25, 2015 at 9:01

1 Answer 1

1

Socket.io is one way, if you want to make a node.js application that acts as a "lighthouse" and redirects requests from the rails application. But be careful with authentication, since if you do it that way, you will have to make it impossible for someone else to use your "lighthouse" in his application for the same purpose. There is a pure rails way of doing that, by using websocket-rails gem: https://github.com/websocket-rails/websocket-rails If you manage to go through the instructions and get it running, you will able to do everything you need to send realtime notifications to the web interface in a pure rails way.

Important note: another issue is making it run on production with passenger and nginx or apache: https://github.com/websocket-rails/websocket-rails/issues/67 http://blog.joshsoftware.com/2013/05/28/websocket-over-nginx/ Here the server needs to be configured correctly to make reverse-proxying websocket requests possible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.