Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Latest value #219

Open
ritsrivastava01 opened this issue Aug 4, 2022 · 2 comments
Open

Publish Latest value #219

ritsrivastava01 opened this issue Aug 4, 2022 · 2 comments

Comments

@ritsrivastava01
Copy link

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!

@mroderick
Copy link
Owner

To me that sounds like this issue: #194

@Lewiscowles1986
Copy link

This one seems more like a debounce / defer or state toggle (disabling button) than request cancellation, but still outside of this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants