当前位置: 首页>>代码示例>>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;未经允许,请勿转载。