本文整理匯總了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()));
}