Hi I’m trying to wrap on how to update a table angular 2.
Here is what I have: Backend: express / MongoDB. Updates are feed into the DB via an external app Data: 90% data will will be static. 10% of the data updates every second.
I’ve looked at Observables / promises. HTTP requests/ socket IO but can’t wrap my mind around the concepts.
Main Question: can I use observables with socket.io to update records?
Other Questions about data updates
- Angular 2’s Observables – are observables use only when the client is pulling data? or can you use it with a socket when data is being pushed to the client. (all examples online use observables with a http request)
- Can you use Socket IO to update an object or is it just for new objects? Every example is see is a chat application.
- When using http requests how do you set how often the data is requested? (some examples online use loops but that seems wrong.)
Observables are event-based so they can be used to receive events from server leveraging web sockets. Have a look at this article (section "Event-based support"):
In fact it's new objects but you can leverage the
scan
operators to aggregate the content of several events.See this question for more details:
If you want to pull with a time interval, you can leverage the
interval
method: