I've been looking at the Netflix Falcor demo project, and have modified an example which adds a title, then immediately removes a title. When I run the following code repeatedly though, the last title in the list after the remove, (printed at 'titles after remove') is different every time.
Sometimes the last title is undefined, sometimes it still contains the pushed title, and sometimes the new title is appended causing the list of titles to slowly grow over time. This seems very buggy (or am I doing something wrong?)
model.get('genrelist[0].titles.length')
.then(function(z) {
var length = z.json.genrelist[0].titles.length;
model.getValue('genrelist[0].titles[0..' + length + '].name')
.then(function(titles){
console.log('titles before push:', titles);
model.call('genrelist[0].titles.push',
[{$type: "ref", value: ['titlesById', 3]}],
["name", "rating"], ["length"]
).then(function(x) {
model.getValue('genrelist[0].titles[0..' + length + '].name')
.then(function(titles){
console.log('titles after push:', titles);
var index = x.json.genrelist[0].titles.length - 1;
model.call('genrelist[0].titles.remove', [index])
.then(function(y) {
model.get('genrelist[0].titles[' + (index + 1) + ']["name", "year"]')
.then(function() {
model.get('genrelist[0].titles.length')
.then(function(w) {
model.getValue('genrelist[0].titles[0..' + length + '].name')
.then(function(titles){
console.log('titles after remove:', titles);
},jerror);
});
}, jerror);
}, jerror);
},jerror);
}, jerror);
},jerror);
}, jerror)