phillbaker / digitalocean-node

Unofficial node client for the v2 DigitalOcean API
http://phillbaker.github.io/digitalocean-node
MIT License
67 stars 16 forks source link

Lazy pagination of index lists #17

Closed phillbaker closed 6 years ago

phillbaker commented 7 years ago

It'd be great to not expose the internals of DO's API pagination. We should return a array-like object that handles the pagination internally.

JS generators and iterators could be used under the hood to power this.

omgimanerd commented 7 years ago

I'm not sure if this is a good idea, but something I did when calling functions was:

client.droplets.listActions(dropletID, 1, Number.MAX_SAFE_INTEGER, callback);

Using 1 page with all the resources on that page?

I guess if that's not a good idea, one could return an iterator that stores a constant number of objects internally, and when the code requires more, another request is made.

phillbaker commented 7 years ago

Ah, unfortunately there's a hardcoded max of 200 on the API side: https://developers.digitalocean.com/documentation/v2/#links.

I guess if that's not a good idea, one could return an iterator that stores a constant number of objects internally, and when the code requires more, another request is made.

👍 Stripe does a great job of this in their ruby api bindings.

phillbaker commented 6 years ago

Closed by 72932c074fceaaf9d4719699cd91696227214f4e