mharris717 / ember-cli-pagination

Pagination Addon for Ember CLI
MIT License
273 stars 116 forks source link

PagedRemoteArray AND content observer #250

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello,

I'm using PagedRemoteArray. I have a situation where I have an observer that looks at content.@each.someRelationship When it fires I want to completely refresh the content.

Problem is that when I go to some other page, it will also fire that observer because it picks up the new content. And I have no access over that promise.

Is there a "before" and "after" action I can hook onto when the promise finishes to load the next content?

ghost commented 6 years ago

tried this

                PagedRemoteArray.extend({
                    stuffChanged: Ember.observer('content.contentUpdated', function() {
                        alert('changed');

                    })

                })

as well as observing contentWillChange

but doesn't sync up so I can filter.

ghost commented 6 years ago

when the observer fires, I want to reload the entire content entirely (not only a single page). which is fine.

But on next/previous page, the observer fires and in this case I want to prevent reloading entirely.

for example, when I hit page 2, and the observer fires, I want to prevent the reload from being called to create new PagedRemoteArray.

ie:

reload() {
 PagedRemoteArray.create(data);
  //etc...
},
reloadContent: Ember.observer('content.@each.someRelationship', function() {
  //if page was clicked, I want to prevent the following
   reload();
})

there is no way I am able to sync up and prevent reloading when the observer fires.

I have tried all sorts of low-level stuff and can't get this to work.

I tried dynamically adding and removing observers, same issue.