Cursor based, API without count key
See original GitHub issueHi there! Thanks for the awesome paging component!
I’m using ember-infinity with version 1.0.0.beta-4.
And I’m building an api with no total_pages. I’m following the tutorial in README but I’m having a problem because, _canLoadMore
need to be updated when have no more entities to load. How can achieve this?
Today the component continuously call the api (incrementing the page) but with no data…
// mixin
import InfinityModel from 'ember-infinity/lib/infinity-model';
import { computed } from '@ember/object';
export default InfinityModel.extend({
_canLoadMore: computed('content', 'perPage', function() {
console.log('I am just called once!');
let results = this.get('content').length;
return results > 0 && results == this.get('perPage');
}).readOnly()
})
// route...
import Route from './list-route';
import InfinityLoader from '../mixins/infinity';
export default Route.extend({
model(params) {
params = this._super(...arguments); // setting startingPage, perPage n others.
return this.infinityModel('opinion', params, InfinityLoader);
},
afterInfinityModel(posts) {
console.log('I am not fired :/');
}
});
My ideia is load all entities but when a page was returned with data insufficient (lower than a full page) I get false, and then the message was showed up.
Any help is appreciated!
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Evolving API Pagination at Slack
Cursor -based pagination works by returning a pointer to a specific item in the dataset. On subsequent requests, the server returns results after...
Read more >Cursor-Based API Pagination - FME Community - Safe Software
Part 2: Create a Cursor-Based Pagination Loop · 1. Separate the JSON Keys in the Response · 2. Filter the JSON Keys ·...
Read more >How to Implement Cursor Pagination Like a Pro
But first, let's discuss the ideal scenario. Cursor Implementation. If offset pagination is an array, then cursor pagination is a linked list.
Read more >Cursor Based Pagination for search results without ...
In this situation, the cursor value is not static and cannot be stored in your searchable record. It has to be calculated based...
Read more >API pagination techniques - Sam's space
The cursor (keyset) based pagination, however, is faster and does not miss any records. Sorting is part of the implementation, so it's less ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ya’ll are awesome! 1.0.0-beta.6 published.
I haven’t had a use case for afterModelHook in my current projects so lmk if you run into any other problems!
@johncalvinyoung @brunoocasali 👋 We released 1.0 today! So lmk what we can do to improve keyset pagination. (I think John still has an outstanding PR that we can help get in now).