本文整理汇总了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"))));
}
示例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>"))
);
}
示例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();
}
})
);
}
示例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);
}
示例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()));
}