Skip to content

Commit

Permalink
Add ToProperty overload which sets the backing field via out parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaanstra committed Aug 28, 2013
1 parent 69f4b7a commit c93bb21
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ReactiveUI/ObservableAsPropertyHelper.cs
Expand Up @@ -186,6 +186,36 @@ public static class OAPHCreationHelperMixin

return ret;
}

/// <summary>
/// Converts an Observable to an ObservableAsPropertyHelper and
/// automatically provides the onChanged method to raise the property
/// changed notification.
/// </summary>
/// <param name="source">The ReactiveObject that has the property</param>
/// <param name="property">An Expression representing the property (i.e.
/// 'x => x.SomeProperty'</param>
/// <param name="initialValue">The initial value of the property.</param>
/// <param name="scheduler">The scheduler that the notifications will be
/// provided on - this should normally be a Dispatcher-based scheduler
/// (and is by default)</param>
/// <returns>An initialized ObservableAsPropertyHelper; use this as the
/// backing field for your property.</returns>
public static ObservableAsPropertyHelper<TRet> ToProperty<TObj, TRet>(
this IObservable<TRet> This,
TObj source,
Expression<Func<TObj, TRet>> property,
out ObservableAsPropertyHelper<TRet> result,
TRet initialValue = default(TRet),
IScheduler scheduler = null)
where TObj : ReactiveObject
{
var ret = source.ObservableToProperty(This, property, initialValue, scheduler);

result = ret;
return ret;
}

}
}

Expand Down

0 comments on commit c93bb21

Please sign in to comment.