Skip to content

Commit d682d7f

Browse files
committed
Add AsObservable
1 parent e1c2739 commit d682d7f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/R3/BindableReactiveProperty.cs

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface IReadOnlyBindableReactiveProperty<T> : IReadOnlyBindableReactiv
2121
IReadOnlyBindableReactiveProperty<T> EnableValidation(Func<T, Exception?> validator);
2222
IReadOnlyBindableReactiveProperty<T> EnableValidation<TClass>([CallerMemberName] string? propertyName = null!);
2323
IReadOnlyBindableReactiveProperty<T> EnableValidation(Expression<Func<IReadOnlyBindableReactiveProperty<T>?>> selfSelector);
24+
Observable<T> AsObservable();
2425
}
2526

2627
public interface IBindableReactiveProperty : IReadOnlyBindableReactiveProperty
@@ -317,6 +318,11 @@ IReadOnlyBindableReactiveProperty<T> IReadOnlyBindableReactiveProperty<T>.Enable
317318
enableNotifyError = true;
318319
return this;
319320
}
321+
322+
public Observable<T> AsObservable()
323+
{
324+
return this;
325+
}
320326
}
321327

322328
internal sealed class PropertyValidationContext(ValidationContext context, ValidationAttribute[] attributes)

src/R3/ReactivePropertyExtensions.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
namespace R3;
1+
using System.Collections;
2+
using System.ComponentModel;
3+
using System.Linq.Expressions;
4+
using System.Runtime.CompilerServices;
5+
6+
namespace R3;
27

38
public static class ReactivePropertyExtensions
49
{
@@ -30,12 +35,12 @@ public static BindableReactiveProperty<T> ToBindableReactiveProperty<T>(this Obs
3035
return new BindableReactiveProperty<T>(source, initialValue, equalityComparer);
3136
}
3237

33-
public static IBindableReactiveProperty<T> ToReadOnlyBindableReactiveProperty<T>(this Observable<T> source, T initialValue = default!)
38+
public static IReadOnlyBindableReactiveProperty<T> ToReadOnlyBindableReactiveProperty<T>(this Observable<T> source, T initialValue = default!)
3439
{
3540
return new BindableReactiveProperty<T>(source, initialValue, EqualityComparer<T>.Default);
3641
}
3742

38-
public static IBindableReactiveProperty<T> ToReadOnlyBindableReactiveProperty<T>(this Observable<T> source, IEqualityComparer<T>? equalityComparer, T initialValue = default!)
43+
public static IReadOnlyBindableReactiveProperty<T> ToReadOnlyBindableReactiveProperty<T>(this Observable<T> source, IEqualityComparer<T>? equalityComparer, T initialValue = default!)
3944
{
4045
return new BindableReactiveProperty<T>(source, initialValue, equalityComparer);
4146
}
@@ -74,3 +79,4 @@ protected override void OnCompletedCore(Result result)
7479
}
7580
}
7681
}
82+

0 commit comments

Comments
 (0)