A
A
Andrey Myvrenik2016-10-10 14:28:25
Android
Andrey Myvrenik, 2016-10-10 14:28:25

How to correctly implement a list with real-time data updated?

Let's say the application loads a list of items (the number is not known in advance) and displays data about them in a RecyclerView. After downloading, data about specific elements may change and all clients need to update information about changed elements as soon as possible. Actually a question - how it is the most effective to implement it? Is there an example or pattern for solving this problem using WebSocket or long polling? Please point me in the right direction.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2016-10-10
@gim0

We did it like this:
Any change / addition / deletion of data creates a record with a non-breaking id in the database.
API methods:
1) returns all data objects in their entirety + id of the last change record
2) a method that returns change records with id in the specified interval.
3) a socket in which records about changes come in realtime. (done on node.js + socket.io, it is implemented very quickly and simply out of the box)
Application logic:
Download all objects from the method [1].
We start listening to the socket [3], if we receive a record with id > last_id+1, we request the difference from the method [2]

D
davidnum95, 2016-10-11
@davidnum95

You can try Firebase. He just solves the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question