Path is empty for changes to class from own method
woubuc opened this issue · 1 comments
woubuc commented
When changing a property on a class instance from within a method in that class, the callback is called with an empty path instead of the property that was changed.
import onChange from 'on-change';
class Foo {
constructor() {
this.bar = true;
}
toggle() {
this.bar = !this.bar;
}
}
let foo = onChange(
new Foo(),
(path) => console.log(path),
{ pathAsArray: true },
);
foo.toggle();
// Output: [] ❌
// Expected: ['bar']
foo.bar = !foo.bar;
// Output: ['bar'] ✔️
dtcooper commented
Ever find a workaround for this? Thanks!