nx-js / observer-util

Transparent reactivity with 100% language coverage. Made with ❤️ and ES6 Proxies.
MIT License
1.2k stars 94 forks source link

Should Symbols be observable? #11

Closed solkimicreb closed 7 years ago

solkimicreb commented 7 years ago

Should properties with Symbol keys trigger observed functions, when they change value?

Currently Symbols are observable with the exception of well-known Symbols. The reason is that well- known symbols are frequently used internally by JS, which would lead to unexpected observed function triggers and performance issues.

The more I use the observer-util the more I feel like this should be extended to all Symbols. Symbols are generally used to store internal low-level data, which should not be observed.

What's your opinion? Is there anyone who relies on observing Symbol keyed properties?

CheloXL commented 7 years ago

I don't know how other people use this library and maybe that's something that's up to you (because this library is, after all, part of a bigger framework).

I for myself don't think that properties with symbols should be observed. In fact (and this is my point of view), the observable model should be a plain POCO. So, no symbols, not even Map/Set. Just simple JS primitives. After all, I usually observe a POCO object that the server gives me and after all the changes, I submit it back for updates (or a new one if I'm creating a new entry... not really a point here).

Of course I do use Map/Set/Symbols, but as you mentioned, usually to manage some internal state that should not be exposed and of course, not observed.

solkimicreb commented 7 years ago

I think I will make symbol keyed and function valued properties non observable, because they do not express data (rather metadata and functionalities). Maps and Sets will stay observable though.

Edit: I might allow the users to fine tune it with a config in the future if there is need for it.

solkimicreb commented 7 years ago

In the end functions and symbol keyed properties are not observable from version 3 (released today) and upward. Thx for you opinion, it helped me make the decision (: I am closing this issue