2.0.10 • Published 4 years ago

@77io/pagination v2.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Pagination

Pagination makes paginated apis easy to work with. It returns an Observable that emits each page.

Given a base url and (optional) headers, easily grab records in a paginated style.

This works with any api that supports the link header.

An example grabbing all of the posts from the Wordpress api.

import Pagination from "@77io/pagination";
import { last, reduce } from "rxjs/operators";

// Setup the basic options
const baseUrl = wordpressRoot + "/wp-json/wp/v2/posts";
const headers = {
  accept: "application/json"
};

const sub = Pagination(baseUrl, headers)
  .pipe(
    reduce((arr: any[], page: any[]) => {
      return arr.concat(page);
    }, []),
    last()
  )
  .subscribe((allPosts: any[]) => {
    console.log("I got all posts!");
    sub.unsubscribe();
  });

An example getting the first page from the Wordpress api.

import Pagination from "@77io/pagination";

// Setup the basic options
const baseUrl = wordpressRoot + "/wp-json/wp/v2/posts";
const headers = {
  accept: "application/json"
};

const sub = Pagination(baseUrl, headers).subscribe((posts: any[]) => {
  console.log("I got the first page of posts!");
  sub.unsubscribe();
});
2.0.10

4 years ago

2.0.9

4 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago