mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Make map and filter return type with a dispose method
Defined a KnockoutMappedObservableArray type which extends KnockoutSubscription, providing a dispose() method since the mapped arrays require disposal for proper cleanup.
This commit is contained in:
@@ -54,3 +54,11 @@ var complexItems2 = sourceItems.map({
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Test disposal
|
||||
|
||||
evenSquares.dispose();
|
||||
|
||||
complexItems.dispose();
|
||||
|
||||
complexItems2.dispose();
|
||||
|
||||
+7
-4
@@ -5,18 +5,21 @@
|
||||
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
interface KnockoutMappedObservableArray<T> extends KnockoutObservableArray<T>, KnockoutSubscription {
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayFunctions<T> {
|
||||
map<TResult>(mappingOptions: {
|
||||
mappingWithDisposeCallback: (value: T) => {
|
||||
mappedValue: TResult;
|
||||
dispose: () => void;
|
||||
};
|
||||
}): KnockoutObservableArray<TResult>;
|
||||
}): KnockoutMappedObservableArray<TResult>;
|
||||
map<TResult>(mappingOptions: {
|
||||
mapping: (value: T) => TResult;
|
||||
disposeItem?: (mappedItem: TResult) => void;
|
||||
}): KnockoutObservableArray<TResult>;
|
||||
map<TResult>(mappingOptions: (value: T) => TResult): KnockoutObservableArray<TResult>;
|
||||
}): KnockoutMappedObservableArray<TResult>;
|
||||
map<TResult>(mappingOptions: (value: T) => TResult): KnockoutMappedObservableArray<TResult>;
|
||||
|
||||
filter(predicate: (value: T) => boolean): KnockoutObservableArray<T>;
|
||||
filter(predicate: (value: T) => boolean): KnockoutMappedObservableArray<T>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user