Add ko.untrack() to knockout.es5

See 75773a52f5/src/knockout-es5.js (L196)
This commit is contained in:
Juan Luis Boya García 2016-03-19 18:16:23 +01:00
parent dff8e2c625
commit ed3f222909
2 changed files with 8 additions and 2 deletions

View File

@ -54,6 +54,11 @@ class OrderLine {
public getSubtotal(): string {
return "$" + (this.price * this.quantity).toFixed(2);
}
public dispose() {
// Dispose of all the observables of this object to prevent memory leaks
ko.untrack(this);
}
}
class Order {
@ -83,4 +88,4 @@ anOrder.lines.removeAll();
anOrder.lines.destroy(someOrderLine);
anOrder.lines.destroyAll([someOrderLine]);
anOrder.lines.destroyAll();
anOrder.lines.destroyAll();

View File

@ -7,6 +7,7 @@
interface KnockoutStatic {
track(obj: any, propertyNames?: Array<string>): any;
untrack(obj: any, propertyNames?: Array<string>): any;
defineProperty(obj: any, propertyName: string, evaluator: Function): any;
defineProperty(obj: any, propertyName: string, options: KnockoutDefinePropertyOptions): any;
getObservable(obj: any, propertyName: string): KnockoutObservable<any>;
@ -26,4 +27,4 @@ interface Array<T> {
destroy(item: T): void;
destroyAll(items: T[]): void;
destroyAll(): void;
}
}