Skip to content

Commit 71af5f9

Browse files
committed
Fixed improper unbind implementation
1 parent b6a2986 commit 71af5f9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ui/core/bindable.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Binding {
5151
updating = false;
5252
source: observable.Observable;
5353
target: Bindable;
54+
callback: (data: observable.PropertyChangeData) => void;
5455

5556
constructor(target: Bindable, options: BindingOptions) {
5657
this.target = target;
@@ -62,19 +63,19 @@ class Binding {
6263
this.updateTarget(this.source.getProperty(this.options.sourceProperty));
6364

6465
var that = this;
65-
var callback = function (data: observable.PropertyChangeData) {
66+
this.callback = function (data: observable.PropertyChangeData) {
6667
that.onSourcePropertyChanged(data);
6768
}
6869

69-
this.source.addObserver(observable.Observable.propertyChangeEvent, callback);
70+
this.source.addObserver(observable.Observable.propertyChangeEvent, this.callback);
7071
}
7172

7273
public unbind() {
7374
if (!this.source) {
7475
return;
7576
}
7677

77-
this.source.removeObserver(observable.Observable.propertyChangeEvent, this.onSourcePropertyChanged);
78+
this.source.removeObserver(observable.Observable.propertyChangeEvent, this.callback);
7879
this.source = undefined;
7980
this.target = undefined;
8081
}

0 commit comments

Comments
 (0)