could the result of a server query be mutable? #370

Closed
ppcano opened this Issue Aug 24, 2012 · 5 comments

Comments

Projects
None yet
4 participants
@ppcano
Contributor

ppcano commented Aug 24, 2012

I am facing many times with this issue, which seems to be a common situation when client request to paginated/offset resources.

    var content = this.get('content');
    models = App.store.find(Yn.Model, {limit: 3, offset: 3, xxxxxx});
    models.addObserver('isLoaded', function() {
        if (!!content) {
           content.pushObjects(models);
        } else {
           this.set('content', models);
        }
    })

A solution/workaround is to create a mutable array as documented on this stackoverflow post.

I don't know if it could be possible/suitable to improve the result query to be mutable.

@tchak

This comment has been minimized.

Show comment
Hide comment
@tchak

tchak Aug 25, 2012

Member

You should do pagination with an ArrayController not directly on an AdapterPopulatedRecordArray.
https://gist.github.com/1559628

Member

tchak commented Aug 25, 2012

You should do pagination with an ArrayController not directly on an AdapterPopulatedRecordArray.
https://gist.github.com/1559628

@wagenet wagenet closed this Oct 16, 2012

@wagenet

This comment has been minimized.

Show comment
Hide comment
@wagenet

wagenet Oct 16, 2012

Member

If @tchak's suggestion doesn't work for you, let us know.

Member

wagenet commented Oct 16, 2012

If @tchak's suggestion doesn't work for you, let us know.

@JohnEmhoff

This comment has been minimized.

Show comment
Hide comment
@JohnEmhoff

JohnEmhoff Nov 16, 2012

I'm sorry, I'm not sure what you mean with your suggestion? Likewise, I'm trying to append some objects to an ArrayController that was created with data from Ember Data and I get the same error when I call addObjects: https://gist.github.com/4083980

The linked stackoverflow post above gets around this by having a member variable shadow the "real" content attribute, which feels like it should be an unnecessary hack.

I'm sorry, I'm not sure what you mean with your suggestion? Likewise, I'm trying to append some objects to an ArrayController that was created with data from Ember Data and I get the same error when I call addObjects: https://gist.github.com/4083980

The linked stackoverflow post above gets around this by having a member variable shadow the "real" content attribute, which feels like it should be an unnecessary hack.

@wagenet

This comment has been minimized.

Show comment
Hide comment
@wagenet

wagenet Nov 16, 2012

Member

@ppcano, JohnEmhoff the issue is that the results of a find is not a standard array. If you want to manipulate it as a standard array, you should use toArray() once the initial results are loaded.

Member

wagenet commented Nov 16, 2012

@ppcano, JohnEmhoff the issue is that the results of a find is not a standard array. If you want to manipulate it as a standard array, you should use toArray() once the initial results are loaded.

@JohnEmhoff

This comment has been minimized.

Show comment
Hide comment
@JohnEmhoff

JohnEmhoff Nov 21, 2012

Thanks, that's a little cleaner.

Thanks, that's a little cleaner.

@benkonrath benkonrath referenced this issue in onepercentclub/onepercentclub-site Jan 11, 2013

Merged

Properly add wallpost to top of list. #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment