1 min readOct 24, 2019
If, for example, your button press is triggering an API call on your singleton, then just store the resulting cancellable into a variable on your singleton. If the user hits the button again later on, just replace the old value and the prior cancellable will automatically deinit and cancel as needed.
That said, if said API call is using a Combine publisher on URLSession, in most cases the subscription is cancelled anyway as your API call has already returned its data AND completed.