T - The type of items in a PagedResponsepublic class PagedFlux<T> extends PagedFluxBase<T,PagedResponse<T>>
PagedResponse and
also provides the ability to operate on individual items. When processing the response by page,
each response will contain the items in the page as well as the request details like
status code and headers.
To process one item at a time, simply subscribe to this flux as shown below
Code sample
// Subscribe to process one item at a time
pagedFlux
.log()
.doOnSubscribe(
ignoredVal -> System.out.println("Subscribed to paged flux processing items"))
.doOnNext(item -> System.out.println("Processing item " + item))
.doOnComplete(() -> System.out.println("Completed processing"))
.subscribe();
To process one page at a time, use PagedFluxBase.byPage() method as shown below
Code sample
// Subscribe to process one page at a time from the beginning
pagedFlux
.byPage()
.log()
.doOnSubscribe(ignoredVal -> System.out
.println("Subscribed to paged flux processing pages starting from first page"))
.doOnNext(page -> System.out.println("Processing page containing " + page.getItems()))
.doOnComplete(() -> System.out.println("Completed processing"))
.subscribe();
To process items one page at a time starting from any page associated with a continuation token,
use PagedFluxBase.byPage(String) as shown below
Code sample
// Subscribe to process one page at a time starting from a page associated with // a continuation tokenStringcontinuationToken = getContinuationToken(); pagedFlux .byPage(continuationToken) .log() .doOnSubscribe(ignoredVal ->System.out .println("Subscribed to paged flux processing pages starting from first page")) .doOnNext(page ->System.out.println("Processing page containing " + page.getItems())) .doOnComplete(() ->System.out.println("Completed processing")) .subscribe();
PagedResponse,
Page,
Flux| Constructor and Description |
|---|
PagedFlux(Supplier<Mono<PagedResponse<T>>> firstPageRetriever)
Creates an instance of
PagedFlux that consists of only a single page of results. |
PagedFlux(Supplier<Mono<PagedResponse<T>>> firstPageRetriever,
Function<String,Mono<PagedResponse<T>>> nextPageRetriever)
Creates an instance of
PagedFlux. |
byPage, byPage, subscribeall, any, as, blockFirst, blockFirst, blockLast, blockLast, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, bufferTimeout, bufferTimeout, bufferTimeout, bufferTimeout, bufferUntil, bufferUntil, bufferUntilChanged, bufferUntilChanged, bufferUntilChanged, bufferWhen, bufferWhen, bufferWhile, cache, cache, cache, cache, cache, cache, cancelOn, cast, checkpoint, checkpoint, checkpoint, collect, collect, collectList, collectMap, collectMap, collectMap, collectMultimap, collectMultimap, collectMultimap, collectSortedList, collectSortedList, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, compose, concat, concat, concat, concat, concatDelayError, concatDelayError, concatDelayError, concatDelayError, concatMap, concatMap, concatMapDelayError, concatMapDelayError, concatMapDelayError, concatMapIterable, concatMapIterable, concatWith, concatWithValues, count, create, create, defaultIfEmpty, defer, deferWithContext, delayElements, delayElements, delaySequence, delaySequence, delaySubscription, delaySubscription, delaySubscription, delayUntil, dematerialize, distinct, distinct, distinct, distinct, distinctUntilChanged, distinctUntilChanged, distinctUntilChanged, doAfterTerminate, doFinally, doFirst, doOnCancel, doOnComplete, doOnDiscard, doOnEach, doOnError, doOnError, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, elapsed, elapsed, elementAt, elementAt, empty, error, error, error, expand, expand, expandDeep, expandDeep, filter, filterWhen, filterWhen, first, first, flatMap, flatMap, flatMap, flatMap, flatMapDelayError, flatMapIterable, flatMapIterable, flatMapSequential, flatMapSequential, flatMapSequential, flatMapSequentialDelayError, from, fromArray, fromIterable, fromStream, fromStream, generate, generate, generate, getPrefetch, groupBy, groupBy, groupBy, groupBy, groupJoin, handle, hasElement, hasElements, hide, ignoreElements, index, index, interval, interval, interval, interval, join, just, just, last, last, limitRate, limitRate, limitRequest, log, log, log, log, log, log, map, materialize, merge, merge, merge, merge, merge, merge, mergeDelayError, mergeOrdered, mergeOrdered, mergeOrdered, mergeOrderedWith, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequential, mergeSequentialDelayError, mergeSequentialDelayError, mergeSequentialDelayError, mergeWith, metrics, name, never, next, ofType, onAssembly, onAssembly, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureDrop, onBackpressureDrop, onBackpressureError, onBackpressureLatest, onErrorContinue, onErrorContinue, onErrorContinue, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, onErrorStop, onLastAssembly, onTerminateDetach, or, parallel, parallel, parallel, publish, publish, publish, publish, publishNext, publishOn, publishOn, publishOn, push, push, range, reduce, reduce, reduceWith, repeat, repeat, repeat, repeat, repeatWhen, replay, replay, replay, replay, replay, replay, retry, retry, retry, retry, retryBackoff, retryBackoff, retryBackoff, retryBackoff, retryBackoff, retryWhen, sample, sample, sampleFirst, sampleFirst, sampleTimeout, sampleTimeout, scan, scan, scanWith, share, single, single, singleOrEmpty, skip, skip, skip, skipLast, skipUntil, skipUntilOther, skipWhile, sort, sort, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscribeOn, subscriberContext, subscriberContext, subscribeWith, switchIfEmpty, switchMap, switchMap, switchOnFirst, switchOnNext, switchOnNext, tag, take, take, take, takeLast, takeUntil, takeUntilOther, takeWhile, then, then, thenEmpty, thenMany, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timestamp, timestamp, toIterable, toIterable, toIterable, toStream, toStream, toString, transform, transformDeferred, using, using, usingWhen, usingWhen, usingWhen, usingWhen, window, window, window, window, window, window, window, windowTimeout, windowTimeout, windowUntil, windowUntil, windowUntil, windowUntilChanged, windowUntilChanged, windowUntilChanged, windowWhen, windowWhile, windowWhile, withLatestFrom, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWith, zipWith, zipWith, zipWithIterable, zipWithIterablepublic PagedFlux(Supplier<Mono<PagedResponse<T>>> firstPageRetriever)
PagedFlux that consists of only a single page of results. The only
argument to this constructor therefore is a supplier that fetches the first (and known-only) page of T.
Code sample
// A supplier that fetches the first page of data from source/serviceSupplier<Mono<PagedResponse<Integer>>> firstPageRetrieverFunction = () -> getFirstPage();PagedFlux<Integer> pagedFluxInstance = newPagedFlux<>(firstPageRetrieverFunction, nextPageRetriever);
firstPageRetriever - Supplier that retrieves the first page.public PagedFlux(Supplier<Mono<PagedResponse<T>>> firstPageRetriever, Function<String,Mono<PagedResponse<T>>> nextPageRetriever)
PagedFlux. The constructor takes in two arguments. The first
argument is a supplier that fetches the first page of T. The second argument is a
function that fetches subsequent pages of T
Code sample
// A supplier that fetches the first page of data from source/serviceSupplier<Mono<PagedResponse<Integer>>> firstPageRetriever = () -> getFirstPage(); // A function that fetches subsequent pages of data from source/service given a continuation tokenFunction<String,Mono<PagedResponse<Integer>>> nextPageRetriever = continuationToken -> getNextPage(continuationToken);PagedFlux<Integer> pagedFlux = newPagedFlux<>(firstPageRetriever, nextPageRetriever);
firstPageRetriever - Supplier that retrieves the first pagenextPageRetriever - Function that retrieves the next page given a continuation tokenCopyright © 2019 Microsoft Corporation. All rights reserved.