Skip to content
ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target framework is .NET Standard 2.0.
C# HTML Vim Snippet
Branch: master
Clone or download

Latest commit

Latest commit b39ac94 Feb 26, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vs/config change target .net standard 1.1 Jul 9, 2016
Assets Change folder layout Jan 22, 2019
BuildTools update the version number Jan 17, 2020
Images change readme.md Jan 24, 2018
Sample v6.1.4 Nov 16, 2019
Snippet Add ReactivePropertySlim code snippet Feb 17, 2020
Source update the version number Jan 17, 2020
Test/ReactiveProperty.Tests impl Jan 17, 2020
docs update Jul 26, 2019
.editorconfig update .editorconfig same as roslyn repository Dec 3, 2018
.gitattributes fix multiple subscribe called in ReadOnlyReactiveProperty constructor. Jun 28, 2015
.gitignore Add AsyncReactiveCommand Feb 15, 2017
HowToUseXF-ja.md update howtousexf Jun 16, 2017
HowToUseXF.md update howtousexf Jun 16, 2017
LICENSE.txt Update year in the LICENSE.txt Jan 7, 2018
README-Android.md v2.0.0-pre1 Feb 17, 2015
README-ja.md remove awarded from okazuki Mar 3, 2017
README.md Update README.md Sep 26, 2019
ReactiveProperty.sln Add ReactivePropertySlim code snippet Feb 17, 2020
ReactiveProperty.vsmdi why... diff... Jul 20, 2016
ReleaseNote-ja.md update Rx 4.0.0-preview00001 Jun 16, 2017
ReleaseNote.md change documentation link. Jan 8, 2018
TraceAndTestImpact.testsettings v2.6.1 Apr 2, 2016
UpgradeLog2.htm update libraries. Jun 6, 2017
azure-pipelines.yml update vmimage Apr 8, 2019

README.md

Japanese

ReactiveProperty

ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target framework is .NET Standard 2.0.

ReactiveProperty overview

ReactiveProperty is very powful and simple library.

Delay and Select

This sample app's ViewModel code is as below:

public class MainPageViewModel
{
    public ReactiveProperty<string> Input { get; }
    public ReadOnlyReactiveProperty<string> Output { get; }
    public MainPageViewModel()
    {
        Input = new ReactiveProperty<string>("");
        Output = Input
            .Delay(TimeSpan.FromSeconds(1))
            .Select(x => x.ToUpper())
            .ToReadOnlyReactiveProperty();
    }
}

It's LINQ and Rx magic.

All steps are written getting started section in the ReactiveProperty documentation.

This library's concept is "Fun programing". ViewModel code which using ReactiveProperty is very simple.

ViewModel's popular implementation is as below:

public class AViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private string _name;
    public string Name
    {
        get => _name;
        set
        {
            _name = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));

            // Update a command status
            DoSomethingCommand.RaiseCanExecuteChanged();
        }
    }

    private string _memo;
    public string Memo
    {
        get => _memo;
        set
        {
            _memo = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Memo)));

            // Update a command status
            DoSomethingCommand.RaiseCanExecuteChanged();
        }
    }

    // DelegateCommand is plane ICommand implementation.
    public DelegateCommand DoSomethingCommand { get; }

    public AViewModel()
    {
        DoSomethingCommand = new DelegateCommand(
            () => { ... },
            () => !string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Memo)
        );
    }
}

Binding code is as below:

<TextBlock Text="{Binding Name}">
<TextBlock Text="{Binding Memo}">

ViewModel's implementation using ReactiveProperty is as below:

public class AViewModel
{
    public ReactiveProperty<string> Name { get; }
    public ReactiveProperty<string> Memo { get; }
    public ReactiveCommand DoSomethingCommand { get; }

    public AViewModel()
    {
        Name = new ReactiveProperty<string>()
            .SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "Invalid value" : null);
        Memo = new ReactiveProperty<string>()
            .SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "Invalid value" : null);
        DoSomethingCommand = new[]
            {
                Name.ObserveHasErrors,
                Memo.ObserveHasErrors,
            }
            .CombineLatestValuesAreAllFalse()
            .ToReactiveCommand()
            .WithSubscribe(() => { ... });
    }
}

Binding code is as below:

<TextBlock Text="{Binding Name.Value}">
<TextBlock Text="{Binding Memo.Value}">

It's very simple.

ReactiveProperty doesn't provide base class by ViewModel. It's means that ReactiveProperty can use together the another MVVM library like Prism, MVVMLight, etc...

Documentation

ReactiveProperty documentation

NuGet

ReactiveProperty

Support

I'm not watching Stackoverflow and other forums to support ReactiveProperty, so please feel free ask to question at Github issues. I'm available Japanese(1st language) and English(2nd language).

If questions became huge numbers, then I would separate posting place about feature requests, issues, questions.

Author info

Yoshifumi Kawai a.k.a. @neuecc is software developer in Tokyo, Japan. Awarded Microsoft MVP for Visual Studio and Development Technologies since April, 2011. He is an original owner of ReactiveProperty.

Takaaki Suzuki a.k.a. @xin9le software devleoper in Tokyo, Japan. Awarded Microsoft MVP for Visual Studio and Development Technologies since July, 2012.

Kazuki Ota a.k.a. @okazuki software developer in Tokyo, Japan. Awarded Microsoft MVP for Windows Development since July 2011 to Feb 2017. Now, working at Microsoft Japan.

You can’t perform that action at this time.