Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'd wrap up modifications that happen within a certain time period.
Eg, if the comment count gets modified,
The client receives an update every 3 seconds, that contains the updated data of the last 3 seconds. -
@metamourge
This. I tend to like rolling backoffs as well. I'll keep a pair per user in an actor state for active session. The longer a user goes without seeing an update that contains new data, the longer the backoff gets to a set space.
For things like this I'll do 2^nth to 16, then default to a 60s periodicity check. -
hitzoR2634yWell, websockets are designed to update the page many times per second. If you wrap multiple messages in some timeframe into one update, it isn't really realtime.
-
kiki353634yIf you can fuck up at this, the fuckup itself will happen with rerendering. I’d recommend save the link to your counter element to query dom on update exactly one time and rerendering exactly one dom node. Also throttle the update function.
-
Thanks I'll take these under advisement.
Another idea i just considered is this.
-When the new comment is added, the client is notified through socket with the "id" of the post that owns the comment.
-Then the client identifies the particular post in the posts list object and just updates only the "count" property. (No update will happen if the post is not in view or not loaded in the posts list object).
This will prevent full refresh and also the client will only worry about the posts currently on the users view. -
hitzoR2634y"Full refresh"? Why would you do that? Just send the post data in the websocket message. You shouldn't need to query something extra after the client receives ws message.
-
@hitzoR
Oh not what you think. It's about updating comments count on each posts.
Just like the main rants page. Each post in the list shows comments count. So to update these counts individually in real time when new comment is added while the user is still on the main page. -
hitzoR2634y@rantingduck Just use pub/sub and dynamically subscribe to or unsubscribe from posts which are entering or leaving the viewport. With each comment send comments count to the channel of the post and you're good to go
I've been working on a project that involves realtime messaging and i intend to also allow the comments count to update in real-time with websocket.
What i currently do is, when a user post's a comment the socket is notified to refresh the posts list page. (But if many users are commenting simultaneously that would be so many updates per few seconds. )
What's the best way around realtime comment-count updates in webapps.
question