goinstant / goangular

AngularJS bindings for GoInstant. Build realtime, multi-user apps with AngularJS and GoInstant easily. https://developers.goinstant.com/v1/GoAngular/index.html
BSD 3-Clause "New" or "Revised" License
137 stars 30 forks source link

Inefficient scope notifications on model updates #95

Open mattcreager opened 10 years ago

mattcreager commented 10 years ago

The issue has been replicated in this plunker.

Each $set operation should be followed by a single $watchCollection event being triggered. As is demonstrated in the plunker, an additional event is being triggered, as the model is cleared and refreshed with the current data.

artch commented 10 years ago

The similar problem still exists when dealing with child arrays. I've created a fork of your plunker illustrating the issue.

The output is:

model is: undefined was: undefined 
model is: ["d", "e", "f"] was: undefined 
model is: undefined was: ["d", "e", "f"] 
model is: ["a", "b", "c"] was: undefined 
model is: undefined was: ["a", "b", "c"] 
model is: ["d", "e", "f"] was: undefined 

As you can see, there are odd model is: undefined runs while performing only two $sets. This behavior leads to undesirable animation issues.

mattcreager commented 10 years ago

Ah, arrays are being handled as primitive values, we need to implement the same solution for both primitives and objects, thanks again @artch I'll drop a PR in :)

artch commented 10 years ago

Any progress with this? It really hurts when it comes to animation in many cases.