The library for fetching data from endpoints that uses continuationToken.
Go to file
2019-11-29 16:58:22 +03:00
src clean up 2019-11-28 15:41:32 +03:00
.gitignore Linter added. Tests enabled. Dist clean up. 2019-11-28 15:25:43 +03:00
.prettierignore Initial commit 2019-11-27 19:31:56 +03:00
.prettierrc Initial commit 2019-11-27 19:31:56 +03:00
jasmine.json jasmine clean up 2019-11-28 15:28:33 +03:00
LICENSE LICENSE file added 2019-11-27 20:39:00 +03:00
package-lock.json road to es5 2019-11-29 15:36:07 +03:00
package.json Create README.md (#6) 2019-11-29 16:58:22 +03:00
README.md Create README.md (#6) 2019-11-29 16:58:22 +03:00
tsconfig.json road to es5 2019-11-29 15:36:07 +03:00
tslint.json Initial commit 2019-11-27 19:31:56 +03:00

Partial-fetcher

The library for fetching data from endpoints that uses continuationToken.


API answers something like this?

Response {
	result: any[];
	continuationToken?: string;
}

Use a partial-fetcher!


Why partial-fetcher so great? Because supports things like doAction, hasMore, fetchMore.


Installation

  • Add .npmrc file into your root directory in your project with this line
@rbkmoney:registry=https://npm.pkg.github.com/
  • Login into github npm registry (Guide)

  • Install partial-fetcher via

npm i --save @rbkmoney/partial-fetcher

Usage

  • Extend your service class with PartialFetcher like this where R is result type and P search params type
Service extends PartialFetcher<R, P>
  • Declare protected fetch method
fetch(params: P, continuationToken: string): Observable<FetchResult<R>>
  • Search your items with search method, update items with refresh, load more with fetchMore.

  • Get your items from searchResult$, check if it has more with hasMore$, get loading state from doAction$ and subscribe to errors with errors$.

  • You're awesome!