ReactiveProperty

ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target frameworks are .NET 6+, .NET Framework 4.7.2 and .NET Standard 2.0.

MIT License

Stars
870
Committers
29

ReactiveProperty.XamarinAndroid

ReactiveProperty.XamarinAndroid is MVVM support library for ReactiveProperty + Xamarin.Android environment.

Features

  • OneWay and TwoWay databinding, between View's property and ReactiveProperty.
  • IList, ObservableCollection and ReadOnlyObservableCollection convert to IListAdapter.
  • View classes(ex, Button, TextView...) event provide extension method "EventName"AsObservable.

DataBinding

This ViewModel class is here.

public class VM
{
  // ViewModel Property
  public ReactiveProperty<string> Output { get; set; }

  public VM() { this.Output = new ReactiveProperty(); }
}

OneWay databinding.

var vm = new VM();

this.FindViewById<TextView>(Resource.Id.TextView)
  .SetBinding(
    x => x.Text, // select target property
    vm.Output); // source property

TwoWay databinding

var vm = new VM();

this.FindViewById<EditText>(Resource.Id.EditText)
  .SetBinding(
    x => x.Text, // select target property
    vm.Output,  // source property
    x => x.TextChangedAsObservable().ToUnit()); // update source trigger

Command binding

SetCommand extension methods can be found in IObservable .

this.FindViewById<Button>(Resource.Id.Button)
  .ClickAsObservable()
  .SetCommand(vm.AlertCommand);

Collection binding

Collection type can convert to IListAdapter.

public class VM
{
  public ReadOnlyReactiveCollection<string> Values { get; private set; }
}


var vm = new VM();
this.FindViewById<ListView>(Resource.Id.ListView)
    .Adapter = vm.Values.ToAdapter(
      (index, value) => LayoutInflator.FromContext(this).Inflate(Android.Resource.Layout.SimpleListItem1) // create view
      (index, value, view) => view.FindViewById<TextView>(Android.Resource.Id.Text1).Text = value, // setup view
      (index, value) => value.GetHashCode()); // generate id

many many many... extension methods

here

Package Rankings
Top 4.35% on Proxy.golang.org
Related Projects