diff --git a/knockout.es5/knockout.es5-tests.ts b/knockout.es5/knockout.es5-tests.ts index f35ea44b84..4177d303b0 100644 --- a/knockout.es5/knockout.es5-tests.ts +++ b/knockout.es5/knockout.es5-tests.ts @@ -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(); \ No newline at end of file +anOrder.lines.destroyAll(); diff --git a/knockout.es5/knockout.es5.d.ts b/knockout.es5/knockout.es5.d.ts index a62f5d8a81..06309059ef 100644 --- a/knockout.es5/knockout.es5.d.ts +++ b/knockout.es5/knockout.es5.d.ts @@ -7,6 +7,7 @@ interface KnockoutStatic { track(obj: any, propertyNames?: Array): any; + untrack(obj: any, propertyNames?: Array): any; defineProperty(obj: any, propertyName: string, evaluator: Function): any; defineProperty(obj: any, propertyName: string, options: KnockoutDefinePropertyOptions): any; getObservable(obj: any, propertyName: string): KnockoutObservable; @@ -26,4 +27,4 @@ interface Array { destroy(item: T): void; destroyAll(items: T[]): void; destroyAll(): void; -} \ No newline at end of file +}