question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cursor based, API without count key

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
snewcomercommented, May 9, 2018

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!

1reaction
snewcomercommented, Jun 18, 2018

@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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found