sindresorhus/on-change

onChange() fires only once if a child object referenced multiple times in a watched object is modified

Opened this issue · 0 comments

Hi all!

I am not sure if this is a bug or a feature.
I'll call it a bug as I would have expected a different behavior.

Current behaviour:

  • I have a child object (let's call it multiRefChild) referenced at multiple places in a watched object obj as obj.child1 and obj.child2.
  • If I change a property a in the obj.child1 it fires an onChange() event for the obj.child1.a path, but not for the obj.child2.a path, even though obj.child2.a has also changed.

Expected behaviour:

  • If I change a property a of the obj.child1 it fires an onChange() event for the obj.child1.a path as well as the obj.child2.apath.

Working example

Is this a bug or a feature?

If it's a feature, it might deserve a mention in the readme ;-)

Thanks for the library and for your time!