can-map-compat
makeMapCompat(Type)
Makes an observable type, such as can-define/map/map or an ObserveObject compatible with the can-map APIs such as attr and removeAttr.
import makeMapCompat from "can-map-compat";
import DefineMap from "can-define/map/map";
var MyMap = makeMapCompat(DefineMap.extend({
count: {
type: "number",
default: 0
}
}));
var map = new MyMap({ count: 0 });
map.attr("count", 1);
console.log(map.attr("count")); // -> 1
map.removeAttr("count");
console.log(map.attr("count")); // -> undefined
Parameters
- Type
{Object}
:The Type to make compatible with can-map.
Returns
{Object}
:
The Type, with the can-map methods added.