Coder Social home page Coder Social logo

Paginate Message APIs about server HOT 6 CLOSED

gotify avatar gotify commented on May 13, 2024
Paginate Message APIs

from server.

Comments (6)

lslah avatar lslah commented on May 13, 2024

since=id is probably better as two messages might have the same date, see https://coderwall.com/p/lkcaag/pagination-you-re-probably-doing-it-wrong

from server.

jmattheis avatar jmattheis commented on May 13, 2024

@lslah Using ids for pagination seems to be better. Good point!

from server.

naimo avatar naimo commented on May 13, 2024

The name of the parameter seems weird to me : message ids get incremented, so the message received by the server "since" a given id are those with higher numbers.

Keeping the current behavior, the parameter should be renamed "until" or "before". Better though would be to keep "since" but actually return new messages. Seems to be a more frequent use case no ?

from server.

jmattheis avatar jmattheis commented on May 13, 2024

@naimo Naming is hard (:.

I think, I called it this way because the messages are sorted in descending order. Thus, since kinda makes sense. The behavior is also documented

Ascending:
Message 1 |- until 3
Message 2 |
Message 3
Message 4 | 
Message 5 |- since 3

Descending:
Message 5 |- until 3
Message 4 |
Message 3
Message 2 | 
Message 1 |- since 3

I don't think this renaming would justify a breaking API change.

Better though would be to keep "since" but actually return new messages. Seems to be a more frequent use case no ?

It is actually not because new messages will be transmitted via web socket. Still, the API addition would have some use cases.

from server.

naimo avatar naimo commented on May 13, 2024

from server.

jmattheis avatar jmattheis commented on May 13, 2024

@naimo Yeah, our android app does something similar. I've created #329 to add this functionality.

from server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.