當前位置: 首頁>>代碼示例>>Java>>正文


Java Flux.merge方法代碼示例

本文整理匯總了Java中reactor.core.publisher.Flux.merge方法的典型用法代碼示例。如果您正苦於以下問題:Java Flux.merge方法的具體用法?Java Flux.merge怎麽用?Java Flux.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在reactor.core.publisher.Flux的用法示例。


在下文中一共展示了Flux.merge方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test3

import reactor.core.publisher.Flux; //導入方法依賴的package包/類
@Test
public void test3() {
    Flux<Long> fast = Flux.interval(Duration.ofSeconds(1));
    Flux<Long> slow = Flux.interval(Duration.ofSeconds(3));

    Flux<Long> clock = Flux.merge(
            fast.filter(t -> isFastTime()),
            slow.filter(t -> isSlowTime())
    );

    Flux<LocalDateTime> dateEmitter = Flux.interval(Duration.ofSeconds(1))
            .map(t -> LocalDateTime.now());

    Flux<LocalDateTime> localDateTimeFlux = clock.withLatestFrom(dateEmitter, (tick, date) -> date);

    localDateTimeFlux.subscribe(t -> System.out.println(t.format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"))));
}
 
開發者ID:vgrazi,項目名稱:reactive-demo,代碼行數:18,代碼來源:Samples.java

示例2: clock

import reactor.core.publisher.Flux; //導入方法依賴的package包/類
private static Flux<Long> clock() {
    Flux<Long> fast = Flux.interval(Duration.ofMillis(1000));
    Flux<Long> slow = Flux.interval(Duration.ofMillis(3000));

    return Flux.merge(
            slow.filter(t -> isSlowTickTime()).doOnEach(w -> System.out.println("<SLOW>")),
            fast.filter(t -> !isSlowTickTime()).doOnEach(w -> System.out.println("<FAST>"))
    );
}
 
開發者ID:OlegDokuka,項目名稱:reactive-playing,代碼行數:10,代碼來源:TickTack.java

示例3: getWebsites

import reactor.core.publisher.Flux; //導入方法依賴的package包/類
@Override
public Flux<WebsiteModel> getWebsites(
        WebsiteModel seedWebsite,
        WebsiteModel parentWebsite,
        URI currentUrl,
        Integer depth
) {

    if (depth == 0) urls = new ConcurrentHashMap<>();

    if (depth > MAX_DEPTH) return Flux.just(seedWebsite);

    return Flux.merge(
            Flux.empty(),
            Flux.from(this.getBody(currentUrl))
                    .flatMap((body) -> getWebsiteModel(seedWebsite, parentWebsite, currentUrl.toString(), body, depth))
                    .flatMap((website) -> getParsedUrl(website, seedWebsite.getUrl(), depth))
                    .flatMap((website) -> {
                        LOG.info(Utils.success.log_recursion, depth, seedWebsite.getUrl(), website.getUrl());
                        try
                        {
                            urls.put(website.getUrl(), website);
                            return getWebsites(seedWebsite, website.getParent(), new URI(website.getUrl()), depth + 1);

                        }
                        catch (URISyntaxException e)
                        {
                            LOG.error(e.getMessage());
                            return Flux.empty();
                        }
                    })
    );
}
 
開發者ID:hafidsousa,項目名稱:webcrawler,代碼行數:34,代碼來源:CrawlerBatchService.java

示例4: test3

import reactor.core.publisher.Flux; //導入方法依賴的package包/類
@Test
public void test3() throws InterruptedException {
    Flux<Long> fastTick = Flux.interval(Duration.of(1, ChronoUnit.SECONDS));
    Flux<Long> slowTick = Flux.interval(Duration.of(3, ChronoUnit.SECONDS));

    Flux clock = Flux.merge(
            slowTick.filter(tick -> isSlowTime()),
            fastTick.filter(tick -> isFastTime()));

    Flux<Date> dateFeed = Flux.interval(Duration.of(1, ChronoUnit.SECONDS))
            .map(tick -> new Date());

    clock.withLatestFrom(dateFeed, (tick, date) -> date)
            .subscribe(System.out::println);
}
 
開發者ID:vgrazi,項目名稱:reactive-demo,代碼行數:16,代碼來源:ReactorTests.java

示例5: flux

import reactor.core.publisher.Flux; //導入方法依賴的package包/類
public Flux<T> flux(Object event) {
    return Flux.merge(publisherHolders.stream().map(ph -> ph.get(event)).collect(toList()));
}
 
開發者ID:johnament,項目名稱:reactive-cdi-events,代碼行數:4,代碼來源:ReactorMethods.java


注:本文中的reactor.core.publisher.Flux.merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。