Releases: canjs/can-observable-array
Releases · canjs/can-observable-array
Organize tests for CanJS production tests
Remove the class fields test files to make tests production build for canjs/canjs
suite.
Add babel plugin-proposal-class-properties plugin
v1.1.3 1.1.3
propertyDefaults for observable class fields
Adds propertyDefaults
support to observable class fields
class MyArray extends ObservableArray {
foo = 4;
static get propertyDefaults() {
return type.maybeConvert(String);
}
}
const anArray = new MyArray();
console.log(anArray.foo); // '4'
anArray.on('foo', (ev, newVal, oldVal) => {
console.log(newVal); // -> '10'
});
anArray.set(foo, 10);
Fix expando set
ObservableArray.prototype.set
should not throw error:
class Foo extends ObservableArray{}
const foo = new Foo();
foo.set("count", 3);
Observable class fields support
- Adds observable class fields support:
class Person extends ObservableArray{
greetings = 'Hello';
}
const cherif = new Person();
cherif.on('greetings', function (ev, newVal, oldVal) {
// it should be observable, handle change here
});
// Property change trigger the handler
cherif.greetings = 'Hola';
- Observable class fields support documentation
#78
Fix patches dispatched after mutate methods
const myList = new ObservableArray([0,1]);
myList.push("I am going to hide some changes.");
canReflect.onPatches(myList, function (patches) {
console.log(patches[0].insert[0]); // -> 'Patched after push'
});
myList[1] = "Patched after push";
Dispatch patches for item mutation with 0 value
This fixes event dispatching when an item gets mutated with 0 integer value:
const order = new ObservableArray([0, 1]);
canReflect.onPatches(order, (patches) => {
console.log(order[1]); // -> 0
});
order[1] = 0;
Update listening to event documentation
Fix listening to event documentation.
making sure dispatched patches have correct deleteCount
Dispatch converted items in patch inserts
Prior to this release, listening onPatches
on an ObservableArray would send the original objects that were supplied to push
/unshift
/splice
, even if those objects were converted to an items
type when added to the array.
With this release, the patch listener receives the converted object instead. This resolves some unexpected behavior when building a view based on an ObservableArray in can-view-live.
#73 for more.