Skip to content
Browse files

Add TPL versions of AsyncOneWayBind

  • Loading branch information...
1 parent fe69236 commit 24c34389d22db232831859111c47348b5c02a202 @paulcbetts paulcbetts committed Jan 2, 2013
Showing with 27 additions and 0 deletions.
  1. +27 −0 ReactiveUI/PropertyBinding.cs
View
27 ReactiveUI/PropertyBinding.cs
@@ -6,8 +6,10 @@
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
+using System.Reactive.Threading.Tasks;
using System.Reflection;
using System.Text;
+using System.Threading.Tasks;
namespace ReactiveUI
{
@@ -131,13 +133,38 @@ static BindingMixins()
this TView view,
TViewModel viewModel,
Expression<Func<TViewModel, TProp>> vmProperty,
+ Expression<Func<TView, TOut>> viewProperty,
+ Func<TProp, Task<TOut>> selector,
+ Func<TOut> fallbackValue = null)
+ where TViewModel : class
+ where TView : IViewFor
+ {
+ return binderImplementation.AsyncOneWayBind(viewModel, view, vmProperty, viewProperty, x => selector(x).ToObservable(), fallbackValue);
+ }
+
+ public static IDisposable AsyncOneWayBind<TViewModel, TView, TProp, TOut>(
+ this TView view,
+ TViewModel viewModel,
+ Expression<Func<TViewModel, TProp>> vmProperty,
Func<TProp, IObservable<TOut>> selector,
Func<TOut> fallbackValue = null)
where TViewModel : class
where TView : IViewFor
{
return binderImplementation.AsyncOneWayBind(viewModel, view, vmProperty, null, selector, fallbackValue);
}
+
+ public static IDisposable AsyncOneWayBind<TViewModel, TView, TProp, TOut>(
+ this TView view,
+ TViewModel viewModel,
+ Expression<Func<TViewModel, TProp>> vmProperty,
+ Func<TProp, Task<TOut>> selector,
+ Func<TOut> fallbackValue = null)
+ where TViewModel : class
+ where TView : IViewFor
+ {
+ return binderImplementation.AsyncOneWayBind(viewModel, view, vmProperty, null, x => selector(x).ToObservable(), fallbackValue);
+ }
}
public interface IPropertyBinderImplementation : IEnableLogger

0 comments on commit 24c3438

Please sign in to comment.
Something went wrong with that request. Please try again.