V
V
Vladimir Golub2020-01-14 09:13:08
Node.js
Vladimir Golub, 2020-01-14 09:13:08

How to inform the client about the change on pages with pagination?

One record has changed in the table, how do I inform the client about this change?
As I understand the current page and the number of records displayed on it, I do not know,
since this information is stored on the client. That is, if a record changes,
I need to send an event to the client about it. According to which it send request
with selected page and pagination again but how to do it only if user
is on page with post ? If at this moment it was added, a new record and pagination moved out?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-01-14
@firedragon

Don't send anything this is overengineering. The next time you paginate, just rebuild the paginator.
Or if you can't wait at all, display a badge with the number of new topics in the notification icon.

B
Boris Korobkov, 2020-01-14
@BorisKorobkov

You decide what and how to do:

  1. Do not update anything automatically. As you go to a new page, you will redraw everything. If it turns out to be on a non-existent page - make a redirect to an existing one. Just.
  2. On a timeout from the browser, make ajax requests to the server indicating the current page. If something has changed - redraw, redirect if necessary. Crooked.
  3. Through sockets, the server sends all changes to all clients (or rather, not all, but only those to which a particular client has access). If something has changed - redraw, redirect if necessary. Beautiful.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question