cybercog / laravel-love

Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?

Home Page:https://komarev.com/sources/laravel-love

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating reaction_counters on client side

jandante opened this issue · comments

Hi,

I have a question rather then an issue.

In my user interface when a user clicks on a react button everything gets updated on the server and Laravel Horizon is taking care of updating the counters.

To reflect this update on the client side I want to return the current reaction counters to display them correctly. However my application is quicker to return the counters then Laravel Horizon is in updating the counters. So my application is getting old information to handle.

How are you handling this on the client side?

Should it be completely on the client that we change this? Updating the reaction_counters on the client side doesn't seem normal to do. That implemantion would require to do a lot of things that I don't want on the client side (check what type should be incremented / decremented, if type not yet in the counters create it, maybe someone cancelled his like -> how to intercept that, ...)

Any advice is greatly appreciated and thanks for this package!

@jandante you may increment/decrement the counter on the frontend. On the next page reload user will get the real value. It is not that bad if the user would not see real value from the database instantly.

If action is successful, then return success response and do the math, otherwise do not do anything.

Thanks @antonkomarev . I ended up adding a increment or decrement property to my return value on reacting. When that was available I triggered a local increment / decrement of the counters.