luisherranz / deepsignal

DeepSignal 🧶 - Preact signals, but using regular JavaScript objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] implement "defineProperty" trap as well

rozek opened this issue · comments

Object.defineProperty is a commonly used approach to define new object properties - internally, Reflect.set(...) will invoke Object.defineProperty anyway whenever a new property is to be set.

For that reason, it is a good idea to implement the "defineProperty" trap in order to catch all situations, where new properties are defined.

The required changes should be trivial (see my own fork of your repository)

I've been thinking about this and for the moment I'm not going to add a defineProperty trap. I'm not sure what are the use cases or even if using defineProperty to access the target is actually useful, and I wouldn't like to increase the bundle size unnecessarily.

I'd be happy to review this in the future if there are strong cases to support it, though!