Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created March 15, 2017 00:50
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 yuka1984/c7f942b604eda0c36838884ee04f802b to your computer and use it in GitHub Desktop.
Save yuka1984/c7f942b604eda0c36838884ee04f802b to your computer and use it in GitHub Desktop.
public class MainPageViewModel
{
IService _service;
public MainPageViewModel(IService service, INavigation navigation)
{
_service = service;
Time = service.Time.Do(x => { Debug.WriteLine($"{x} Debug"); }).Select(x => $"{x} 回目").ToReadOnlyReactiveProperty();
CountUpCommand = new AsyncReactiveCommand();
CountUpCommand.Subscribe(async _ => {
GC.Collect();
await Task.Delay(500);
_service.SetTime();
});
GoNextPageCommand = new AsyncReactiveCommand();
GoNextPageCommand.Subscribe(async _ => {
await navigation.PushAsync(new MainPage { BindingContext = new MainPageViewModel(_service, navigation) });
});
}
public ReadOnlyReactiveProperty<string> Time { get; }
public AsyncReactiveCommand CountUpCommand { get; }
public AsyncReactiveCommand GoNextPageCommand { get; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment