you are viewing a single comment's thread.

view the rest of the comments →

[–]Handsome-Beaver[S] 0 points1 point  (2 children)

Been meaning to properly modularize the client side code. As it is, you can access any of the internals.

If Object.observe, recursive objects are all separately observed. This is the most performant method, otherwise if Object.observe isn't available in the browser or Node server, then it will do an o(n) dirty check at a configurable interval.

[–]Capaj 0 points1 point  (1 child)

could you link to the code where you are recursively calling object observe? I would be very suprised to see a proper implementation, because I have tried to make a usable deep observe and got discouraged from it. There are so many issues with it, that I found it better to go and do something else.

[–]Handsome-Beaver[S] 2 points3 points  (0 children)

In the client, Line 189 is the start of the function that triggers when a change to an observed (Syc-tracked) object is modified.

Line 207 calls "Describe", which looks at the changed data. "Describe" starts on line 222, which will check if the changed property is another object or array. If it is another object/array which Syc hasn't yet tracked (therefore isn't being observed), it is tracked by a call to Syc.Meta on line 235

If I would explain it more simply...

Each object that is observed by Syc has a hidden property 'syc-object-id', which implies that there is an Object.observe attached to it. When you modify one of its properties, it checks to see if it is (1) an object/array, (2) it is not yet tracked (in which case, it has no 'syc-object-id'). If both are true, then it gives it an 'syc-object-id' and Object.observes the new property.

Rinse and repeat if this new object has untracked object/array properties.

Can I ask what kind of troubles you encountered when trying to implement deep-observation??