Reputation: 1229
I'm creating a SPA application with AngularJS at the client side and ASP.NET Web API as backend. My database is SQL Server 2012. There will be users which have a favourite sports team and a simple icon in the UI displaying the number of new articles/news/comments added or whatever connected to their favourite teams.
What I'd like to achieve is the following: Whenever a record about their team is inserted (record with TeamID column value for example equal to the user's favourite team ID), that notifications count icon should be updated immediately (just like Facebook's notifications - it's updated when a friend has posted on your wall or has tagged you and so on). How can I best achieve this?
What I'm thinking of for now is just setting an interval function in AngularJS to check every 30 seconds, let's say, if there are new records in the database making a request to a Web API controller. Of course this suggests a lot of checking for when the user is logging out - when was the last check, what will be the date to check against next time he/she logs in and so on.
Upvotes: 1
Views: 1298
Reputation: 1248
What you are looking for is push
Sadly i never used it so i don't know much about it, but i think you should use technologies like pusher
Upvotes: 0
Reputation: 3476
You can use signalR for this. It's a framework for real time communication. Check out this to get if you want to get started. It can easily be used together with angularJS.
Upvotes: 2