$on triggers too early, before model is actually updated
Opened this issue · 2 comments
colinmacdonald commented
$scope.messages = $goKey('messages');
$scope.messages.$add({ text: 'abc123' });
$scope.messages.$on('add', { local: true, listener: function(val, con) {
console.log(val, con, $scope.messages); // val does not exist yet in $scope.messages
}});
I would expect the model to contain the new message when $on
is triggered.
hvdklauw commented
Can confim this happening.
For the sorting of the result from $goQuery I tried to use $key (before this returned the wrong $sync thing, which is now fixed) and was using the $on('ready', ...) to push the synced model to the array. Almost every time AngularJS complains about duplicates in the array and that I need to add a track by (which is there but references a undefined item).
colinmacdonald commented
Thanks for the feedback. This issue and the entire event system is planned to be reworked for release v3.3.0.