Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes #42

Open
wants to merge 2 commits into
base: 1.6
Choose a base branch
from
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