3

As O.o is already been deprecated what are the other options we have to observe the properties of a Javascript Object.

Ashutosh
  • 69
  • 1
  • 6

2 Answers2

1

As stated in the mdn documentation : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe

The Object.observe() method was used for asynchronously observing the changes to an object. It provided a stream of changes in the order in which they occur. However, this API has been deprecated and removed from browsers. You can use the more general Proxy object instead.

Magus
  • 14,796
  • 3
  • 36
  • 51
0

you can achieve this with getters and setters and alternatively, in a browser with support for Proxies, you can write a more generic solution. Check here

Community
  • 1
  • 1
  • 2
    The issue is that you have to plug into the object chain. There is no way to observe changes in a "readymade" object that is parsed from JSON for example.. – Julian F. Weinert Oct 12 '20 at 19:24
  • Implementing this in getters and setters is a lot of boilerplate or 'monkey coding' which leaves technical debt and 'too much code' issues (=more time, more bugs, more time to read, more cost, no more value [than an alternative]). It is a subtle and often unnoticed thief of IT budget. – FastAl Feb 21 '23 at 04:39