Create a gist now

Instantly share code, notes, and snippets.

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