Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/runceel/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.
https://github.com/runceel/ReactiveProperty

c-sharp mvvm reactive-extensions reactiveproperty reative rx uwp wpf xamarin xaml

Last synced: 3 months ago
JSON representation

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.

Awesome Lists containing this project

README

        

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

- Xamarin is [here](https://xamarin.com/).

# 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.
```cs
public class VM
{
// ViewModel Property
public ReactiveProperty Output { get; set; }

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

### OneWay databinding.

```cs
var vm = new VM();

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

### TwoWay databinding

```cs
var vm = new VM();

this.FindViewById(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 .
```cs
this.FindViewById(Resource.Id.Button)
.ClickAsObservable()
.SetCommand(vm.AlertCommand);
```

### Collection binding
Collection type can convert to IListAdapter.
```cs
public class VM
{
public ReadOnlyReactiveCollection Values { get; private set; }
}

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

### many many many... extension methods
[here](https://github.com/runceel/ReactiveProperty/blob/vNext/Source/ReactiveProperty.Platform.Android/Extensions/ViewEventExtensions.cs)