Skip to content

Instantly share code, notes, and snippets.

@flagbug
Created October 21, 2014 19:47
Show Gist options
  • Save flagbug/fd9566a2b4ea41f33289 to your computer and use it in GitHub Desktop.
Save flagbug/fd9566a2b4ea41f33289 to your computer and use it in GitHub Desktop.
ReactiveCommand exceptions

Scenario: ReactiveCommand executes a network request hat can throw an exception. View subscribes to the ThrownExceptions property so it can display a toast message e.g "Request failed"

The user executes the command, but immediately goes to another view, so the current view is destroyed and unsubscribes in WhenActivatedfrom the command. The network request throws a few seconds later, but since there is no subscriber to ThrownExceptions, the application blows up.

@anaisbetts
Copy link

MyCmd = ReactiveCommand.CreateAsyncObservable(_ => DoTheNetworkRequest().TakeUntil(ViewUnloaded));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment