Hacker News new | ask | show | jobs
by franciscop 3275 days ago
Nice, I made something really similar but found it had a bunch of issues. Some of which I don't see addressed here.

When setting an object or array, it will always trigger since the equal comparison will return false even if they have the same { key: value } pairs:

    target[property] !== value
Speaking of which, sub-properties are not being listened to from the root (only if manually listened to on the sub-object):

    obj.foo = { bar: 'baz' }; // triggers
    obj.foo.bar = 'whatever'; // never triggers the base listener
The only realistic automatic way to listen to them is to add a trap for the get, which will proxify the return value if it's an object or array. This has it's own set of errors and turns into a nasty set of edge cases, which is the main reason I never got to release what I was doing. I see in Icaro you Proxify it manually and adding some props on the setter, which leads to this not working as expected:

    const obj = icaro({ foo: { bar: 'baz' } });
    obj.foo.bar = 'baz2';  // Nothing triggers