Skip to content

Instantly share code, notes, and snippets.

@ionoy
Created April 29, 2014 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionoy/11400074 to your computer and use it in GitHub Desktop.
Save ionoy/11400074 to your computer and use it in GitHub Desktop.
public class MainViewModel : ReactiveObject
{
public MainViewModel()
{
LoadTweetsCommand = new ReactiveCommand();
LoadTweetsCommand.RegisterAsync(_ => {
throw new Exception("AA");
return LoadTweets();
}).Subscribe(x => TheTweets = x);
var errorMessage = "The Tweets could not be loaded";
var errorResolution = "Check your Internet connection";
// Any exceptions thrown by LoadTweets will end up being
// sent through ThrownExceptions
LoadTweetsCommand.ThrownExceptions
.Select(ex => new UserError(errorMessage, errorResolution))
.SelectMany(UserError.Throw)
.Where(x => x == RecoveryOptionResult.RetryOperation)
.InvokeCommand(LoadTweetsCommand);
UserError.RegisterHandler(e => Observable.Return(RecoveryOptionResult.));
}
public int TheTweets { get; set; }
private IObservable<int> LoadTweets()
{
return Observable.Return(0);
}
public ReactiveCommand LoadTweetsCommand { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment