Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions MVVM/Views/Bindings/ViewBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static IObservable<Collider2D> OnTrigger2DObservable(this GameObject t, C
/// <typeparam name="T"></typeparam>
/// <param name="t"></param>
/// <returns></returns>
public static T EnsureComponent<T>(this GameObject t) where T : MonoBehaviour
public static T EnsureComponent<T>(this GameObject t) where T : Component
{
if (t.GetComponent<T>() != null) return t.GetComponent<T>();
return t.AddComponent<T>();
Expand Down Expand Up @@ -401,7 +401,7 @@ public static IDisposable DisposeWhenChanged<T>(this IDisposable disposable, P<T
if (onlyWhenChanged)
{
var d =
sourceProperty.Where(p => sourceProperty.LastValue != sourceProperty.ObjectValue)
sourceProperty.Where(p => Object.Equals(sourceProperty.LastValue, sourceProperty.ObjectValue) == false)
.First()
.Subscribe(_ => { disposable.Dispose(); });
return d;
Expand All @@ -426,8 +426,8 @@ public static IDisposable BindProperty<TBindingType>(this IBindable bindable, P<
if (onlyWhenChanged)
{
return
bindable.AddBinding(
property.Where(p => property.LastValue != property.ObjectValue).Subscribe(changed));
bindable.AddBinding(
property.Where(p => Object.Equals(property.LastValue, property.ObjectValue) == false).Subscribe(changed));
}

return bindable.AddBinding(property.Subscribe(changed));
Expand All @@ -450,7 +450,7 @@ public static IDisposable BindTwoWay<TBindingType>(this IBindable bindable, P<TB
{
return
bindable.AddBinding(
property.Where(p => property.LastValue != property.ObjectValue).Subscribe(changed));
property.Where(p => Object.Equals(property.LastValue, property.ObjectValue) == false).Subscribe(changed));
}

return bindable.AddBinding(property.Subscribe(changed));
Expand Down