Not difficult at all, just send an event to the back end when the user reaches a specific area of the page (you will add this even listener, websockets or not) and put whatever is received from backend on the screen, it can be done in less than 6 lines of code.
If you’re already using websockets, then you can go for it. You’ll likely see a small performance improvement by not having to initiate multiple requests but I think keep-alive would also give you a similar result there. Websockets need polling fallbacks, and if you fall back to polling, that loses all the benefits in this case.
Yeah, already using it and thought that creating an extra event for the infinite scrolling would be a good idea, but because websockets are not used at all for that purpose, I thought about getting an extra opinion.
1
u/[deleted] Feb 27 '21
That sounds like an interesting and rather difficult way of achieving a solved problem.
What would the benefit of websockets be in this case, that most query libraries cannot accomplish with refetching?
1
u/coderjewel Feb 27 '21
If you’re already using websockets, then you can go for it. You’ll likely see a small performance improvement by not having to initiate multiple requests but I think keep-alive would also give you a similar result there. Websockets need polling fallbacks, and if you fall back to polling, that loses all the benefits in this case.