Last active
August 1, 2023 21:55
-
-
Save worldbeater/d5888a70445798595c32ecf2c48a996a to your computer and use it in GitHub Desktop.
Assembly Weaving. ReactiveUI.Fody. See: https://medium.com/@worldbeater/reactive-mvvm-for-net-platform-175dc69cfc82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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