Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created June 20, 2021 13:32
Show Gist options
  • Save rdelrosario/3b0325f7866d076ac5b122e48098984d to your computer and use it in GitHub Desktop.
Save rdelrosario/3b0325f7866d076ac5b122e48098984d to your computer and use it in GitHub Desktop.
namespace ReactiveToDoSample.ViewModels
{
public abstract class ViewModelBase : ReactiveObject, IDisposable, INavigable
{
protected ViewModelBase(IParameterViewStackService viewStackService) => NavigationService = viewStackService;
public abstract string Id { get; }
public virtual IObservable<Unit> WhenNavigatedFrom(INavigationParameter parameter) => Observable.Return(Unit.Default);
public virtual IObservable<Unit> WhenNavigatedTo(INavigationParameter parameter) => Observable.Return(Unit.Default);
public virtual IObservable<Unit> WhenNavigatingTo(INavigationParameter parameter) => Observable.Return(Unit.Default);
protected IParameterViewStackService NavigationService { get; }
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
Subscriptions?.Dispose();
}
}
protected readonly CompositeDisposable Subscriptions = new CompositeDisposable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment