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:
Thomas Michon
2015-03-30 19:19:11 -07:00
parent 02a93db66a
commit c124eaac95
2 changed files with 40 additions and 2 deletions
@@ -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: () => { }
};
}
});