I have a livewire component which displays a the count of the number of the number of items in a customer’s wishlist from the database. When someone removes or adds an item to their wishlist, the component is updated with the current count. That’s all working great. The problem is that, because the component appears in two places in my main layout, (I use media queries to hide certain parts of template when viewed using small screen and another when viewed using larger screens) when I fire the event that the wishlist has been added to or subtracted from, the listener in the component is called twice and so TWO calls are made to the database to get the current count.
Without getting into the question of whether I should really just use a session variable to handle the counter display value, is it possible for me to somehow have the component make the database call only once, but update the value for both instances?
Note: someone mentioned at some point somewhere about putting the component in a blade include, and including it twice rather than putting two instances on the page. That did not work… and the database call was still duplicated
Using Laravel 2.2.9
Any thoughts on this? Thanks so much!