Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent results when adding then immediately removing #829

Open
erspark2002 opened this issue Jan 11, 2017 · 0 comments
Open

Inconsistent results when adding then immediately removing #829

erspark2002 opened this issue Jan 11, 2017 · 0 comments

Comments

@erspark2002
Copy link

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?)

Stackoverflow

    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)
@erspark2002 erspark2002 changed the title Inconsistent results in Falcor Inconsistent results when adding then immediately removing Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant