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 have been looking for a proper pattern for commands that can be cancelled.
Here is the scenario:
Joe user wants to log into the twitter service on their device. There is a button on the screen that says twitter and when the user taps on it, the login process starts and the text on the button changes to cancel. The login process could take a long period of time (30 seconds for example) and if the user presses the button again during this time, the existing login will be cancelled.
I have tried many different ways to make this work, but they all have a very bad smell. Here is the best solution I have come up with so far:
Originally I had the twitter command being subscribed to in viewDidLoad and utilizing a takeUntil for the cancel signal (rather than using the disposable and subscribing with the command), but that did not appear to stop the command from executing immediately upon cancellation (the login task would remaining running until the signal processed the takeUntil).
The text was updated successfully, but these errors were encountered:
That worked like a charm and it all smells good. Thanks, it took me a couple days to get as far as I was, I must have missed something when I tried an approach like that last time.
RAC(self.authenticatedUser) = [self.twitterLoginCommand.executionSignals switchToLatest];
if change it to
RAC(self.authenticatedUser) = [self.twitterLoginCommand.executionSignals flatten];
better ? @notxcain
I have been looking for a proper pattern for commands that can be cancelled.
Here is the scenario:
Joe user wants to log into the twitter service on their device. There is a button on the screen that says twitter and when the user taps on it, the login process starts and the text on the button changes to cancel. The login process could take a long period of time (30 seconds for example) and if the user presses the button again during this time, the existing login will be cancelled.
I have tried many different ways to make this work, but they all have a very bad smell. Here is the best solution I have come up with so far:
Originally I had the twitter command being subscribed to in viewDidLoad and utilizing a takeUntil for the cancel signal (rather than using the disposable and subscribing with the command), but that did not appear to stop the command from executing immediately upon cancellation (the login task would remaining running until the signal processed the takeUntil).
The text was updated successfully, but these errors were encountered: