So generally I like the pattern where objects given to components should not be modified. During development, I can use
Object.freeze to assure that and make sure this is really so. On the other hand, I think that when an update to the object comes from the server side, I would just like to modify the object, instead of creating a new object and passing the whole new object to the component, reactively.
So, is there a library already which would do something like that? I am imagining the following API:
const frozenObj = VueFreeze.freeze(obj);
I would pass
frozenObj to the component and no code could change it anymore. Using any property in a reactive context would still register a reactive dependency. Moreover, I could still do something like
obj.foo = 'bar' and that would modify the object, trigger reactive dependency invalidation.
Does something like that exist? Is this reasonable design?