Skip to content

Instantly share code, notes, and snippets.

@worldbeater
Last active August 1, 2023 21:56
Show Gist options
  • Save worldbeater/d18b13811abddf2ced0085cc4ba1d85e to your computer and use it in GitHub Desktop.
Save worldbeater/d18b13811abddf2ced0085cc4ba1d85e to your computer and use it in GitHub Desktop.
[AddINotifyPropertyChangedInterface]
public class FodyReactiveViewModel
{
public ReactiveCommand<Unit, Unit> Clear { get; }
public string Greeting { get; private set; }
public string Name { get; set; } = string.Empty;
public FodyReactiveViewModel()
{
Clear = ReactiveCommand.Create(() => { Name = string.Empty; });
this.WhenAnyValue(x => x.Name)
.Select(name => $"Hello, {name}!")
.Subscribe(x => Greeting = x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment