Skip to content

Instantly share code, notes, and snippets.

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