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
If I tap the button multiple times, the code above will reasonably run for each tap.
What is the best (reactive) way to disregard multiple taps, and respond to a single tap only? I can solve this using semaphores, and setting the button disabled / enabled, but surely there is a more elegant way to do it?
I've tried using debounce(X) but that lets me keep tapping the button for a while, and can still sometimes yield multiple taps.
Also to be clear, I don't want the signal to run only once, so skipDuplicates() doesn't seem quite right either...
Many thanks!
The text was updated successfully, but these errors were encountered:
Is your goal to prevent the async code from running multiple times in parallel? The way I'd recommend doing that is to wrap your async work in a SignalProducer, and then use an Action to bind it to your button.
First define your async work in a function that returns a new SignalProducer:
There are other ways to compose signals and signal producers, but for the purposes of binding work to a button, Action is a really useful tool. (For example, it allows you to display/handle errors separately via its errors signal.)
Apologies if this is obvious - I'm still relatively new to ReactiveSwift...
Right now I have some code like this
If I tap the button multiple times, the code above will reasonably run for each tap.
What is the best (reactive) way to disregard multiple taps, and respond to a single tap only? I can solve this using semaphores, and setting the button disabled / enabled, but surely there is a more elegant way to do it?
I've tried using
debounce(X)
but that lets me keep tapping the button for a while, and can still sometimes yield multiple taps.Also to be clear, I don't want the signal to run only once, so skipDuplicates() doesn't seem quite right either...
Many thanks!
The text was updated successfully, but these errors were encountered: