mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-12 12:10:44 +08:00
Add support for mappingOptions in knockout.projections
Added support for new features introduced in knockout-projections, mappingOptions parameters with either a mapping/disposeItem pair or a single mappingWithDisposeCallback function which produces a mappedItem/dispose pair.
This commit is contained in:
@@ -26,3 +26,31 @@ sourceItems.push(9);
|
||||
|
||||
sourceItems.push(10);
|
||||
// evenSquares now contains [36, 16, 4, 100]
|
||||
|
||||
// Testing mapping options
|
||||
|
||||
interface IComplexItem {
|
||||
value: string;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
var complexItems = sourceItems.map({
|
||||
mapping: x => {
|
||||
var item: IComplexItem = {
|
||||
value: (x * x).toString(),
|
||||
dispose: () => { }
|
||||
};
|
||||
|
||||
return item;
|
||||
},
|
||||
disposeItem: (item: IComplexItem) => item.dispose()
|
||||
});
|
||||
|
||||
var complexItems2 = sourceItems.map({
|
||||
mappingWithDisposeCallback: x => {
|
||||
return {
|
||||
mappedValue: (x * x).toString(),
|
||||
dispose: () => { }
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user