playcanvas / observer

JavaScript implementation of the Observer pattern
https://api.playcanvas.com/modules/Observer
MIT License
16 stars 8 forks source link

Error: value.equals is not a function #10

Closed OliverXH closed 2 years ago

OliverXH commented 2 years ago

Error: value.equals is not a function:

if (value.equals(node._data[key]) && !force) return false;

Here is my code:

const observerData = {
    progress: 30,
    position: [0, 0, 0]
};
const observer = new Observer(observerData);
const history = new History();

let pos = new VectorInput({
    placeholder: ['X', 'Y', 'Z'],
    precision: 3,
    step: 0.05,
    binding: new BindingTwoWay({
        history
    })
});
pos.link(observer, 'position');
container.append(pos);

observer.set('position', [0, 10, 0]);
observer.set('progress', 50);

And I can't find Array.prototype.equals : image

Is there any solution? Or I need to impliment equals by myself?

slimbuck commented 2 years ago

Ahh nasty. This is polyfilled by editor-api, but this should probably moved to observer. You can add the polyfill to your app in the meantime. Sorry for the trouble!