Starcounter / DevTools

A browser extension that helps you debug Starcounter apps with ease
3 stars 1 forks source link

Observing array changes in JSON tree #92

Closed tomalec closed 5 years ago

tomalec commented 5 years ago

@Razkan discovered an issue in dev tools.

Originally, /colab_actionboard_0/Utils/Modals/0/Details/colab_actionboard_0/ShowAllAlternatives/ has 3 elements When JSON Patch is received by the client

[
  {"op":"replace","path":"/_ver#s","value":4},
  {"op":"test","path":"/_ver#c$","value":3},
  {"op":"remove","path":"/colab_actionboard_0/Utils/Modals/0/Details/colab_actionboard_0/ShowAllAlternatives/2"},
  {"op":"add","path":"/colab_actionboard_0/Utils/Modals/0/Details/colab_actionboard_0/ShowAllAlternatives/0","value":{"Id":"B","FullName":"P S","Email":"p.s@test.test","Avatar":"/co-common/test/p.png"}},
  {"op":"add","path":"/colab_actionboard_0/Utils/Modals/0/Details/colab_actionboard_0/ShowAllAlternatives/1","value":{"Id":"D","FullName":"M G","Email":"m.g@test.test","Avatar":"/co-common/test/m.png"}},
  {"op":"remove","path":"/colab_actionboard_0/Utils/Modals/0/Details/colab_actionboard_0/ShowAllAlternatives/3"},
  {"op":"add","path":"/colab_actionboard_0/Utils/Modals/0/Details/colab_actionboard_0/ShowAllAlternatives/2","value":{"Id":"C","FullName":"E M","Email":"e.m@test.test","Avatar":"/co-common/test/m.png"}}]

(which effectively adds 1 to length)

view model is updated:

document.querySelector('palindrom-client').obj.colab_actionboard_0.Utils.Modals[0].Details.colab_actionboard_0.ShowAllAlternatives.length // 4

but JSON tree view shows only Array of 3 elements. Only after Palindrom heartbeat, the JSON tree gets updated.

Seems like a problem similar to observing array splices, as in https://polymer-library.polymer-project.org/2.0/docs/devguide/observers#array-observation

//cc @alshakero