You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm facing one issue using publish method:
I'm using publish method on button click, to add the item in cart: <Button onClick={() => { PubSub.publish("ADD_TO_CART", card); }} > Add to cart </Button>
and I'm listing this in another component: PubSub.subscribe("ADD_TO_CART", function (msg, data) { console.log(data); });
but problem is, when I clicked 3-4 times on the same button, the listener prints all previous value and new value as well. is there any way to publish only latest value not the past values??
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Dear @mroderick ,
Thanks for this awesome library 👍 .
I'm facing one issue using
publish
method:I'm using publish method on button click, to add the item in cart:
<Button onClick={() => { PubSub.publish("ADD_TO_CART", card); }} > Add to cart </Button>
and I'm listing this in another component:
PubSub.subscribe("ADD_TO_CART", function (msg, data) { console.log(data); });
but problem is, when I clicked 3-4 times on the same button, the listener prints all previous value and new value as well. is there any way to publish only latest value not the past values??
Thanks in advance!
The text was updated successfully, but these errors were encountered: