reactive

Why are Flowables not Observables

痞子三分冷 提交于 2019-12-23 12:28:55
问题 Why are Flowables not Observables; Observable interface is pretty much a subset of Flowable, their implementations are pretty much the same. Why don't they implement a common interface so we can directly cast Flowable as Observable? 回答1: A small regret about introducing backpressure in RxJava 0.x is that instead of having a separate base reactive class, the Observable itself was retrofitted. The main issue with backpressure is that many hot sources, such as UI events, can't be reasonably

R Shiny: Creating New Columns Within a Reactive Data Frame

会有一股神秘感。 提交于 2019-12-23 03:19:14
问题 Say I have a data frame called summarized which includes the columns TY_COMP and LY_COMP (among others). I could write a function in R that performs a calculation on TY_COMP and LY_COMP and creates a new column called cac in the data frame like this: summarized$cac <- summarized$TY_COMP/summarized$LY_COMP-1 cac is now a new column in the summarized data frame. Now say that summarized() is a reactive data frame with the same columns. How could I achieve the effect done in the non-reactive data

What's the point of .switchIfEmpty() getting evaluated eagerly?

半世苍凉 提交于 2019-12-23 02:09:12
问题 Even if my stream is not empty, the fallback stream would always be created? What's the intent behind doing this? This is extremely non-idiomatic. On the other hand, . onErrorResume is evaluated lazily. Could someone please explain to me why . switchIsEmpty is evaluated eagerly? Here's the code: public static void main(String[] args) { Mono<Integer> m = Mono.just(1); m.flatMap(a -> Mono.delay(Duration.ofMillis(5000)).flatMap(p -> Mono.empty())) .switchIfEmpty(getFallback()) .doOnNext(a ->

How to set and handle timeout in Spring WebClient?

孤者浪人 提交于 2019-12-23 00:49:19
问题 Spring docs says it is required to configure http client for WebClient manually to set timeouts: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-client-builder-reactor-timeout. But since WebClient returns reactive Mono, it's possible (api-wise) to apply .timeout method. Does it have the same effect? Moreover, when one uses .timeout method, Reactor's TimeoutException is expected. Will the same error appear in the stream if configuration is done

Default number of threads in Spring boot 2.0 reactive webflux configuration

风格不统一 提交于 2019-12-22 11:10:00
问题 While using Spring 5 reactive webflux with Spring boot 2.0, what's the default number of threads used to handle requests? How can I configure the number of threads used? 回答1: The default number of threads for request handling is determined by the underlying web server; by default, Spring Boot 2.0 is using Reactor Netty, which is using Netty's defaults (check out the EventLoopGroup documentation for that). Spring Boot will soon allow you to customize that part (see #10418). In the meantime,

Default number of threads in Spring boot 2.0 reactive webflux configuration

99封情书 提交于 2019-12-22 11:07:04
问题 While using Spring 5 reactive webflux with Spring boot 2.0, what's the default number of threads used to handle requests? How can I configure the number of threads used? 回答1: The default number of threads for request handling is determined by the underlying web server; by default, Spring Boot 2.0 is using Reactor Netty, which is using Netty's defaults (check out the EventLoopGroup documentation for that). Spring Boot will soon allow you to customize that part (see #10418). In the meantime,

How to check if Mono is empty?

走远了吗. 提交于 2019-12-20 10:38:11
问题 I'm developing a app with Spring Boot 2.0 and Kotlin using the WebFlux framework. I want to check if a user id exits before save a transaction. I'm stucked in a simple thing like validate if a Mono is empty. fun createTransaction(serverRequest: ServerRequest) : Mono<ServerResponse> { val transaction = serverRequest.body(BodyExtractors.toMono(Transaction::class.java)) transaction.flatMap { val user = userRepository.findById(it.userId) // If it's empty, return badRequest() } return transaction

Shiny dynamic content based on window size (like css media query)

左心房为你撑大大i 提交于 2019-12-19 09:38:44
问题 I have some plots in a panel. I want to change them into tabsetpanel when the window width is small. Is there any way in shiny to determine window width of browser. For example, in the following example, how can I switch uiOutput from plotPanel1 to plotPanel2 when the window width is large enough. library(ggplot2) ui <- fluidPage( title = "TestApp", h1("Test Application"), sidebarLayout( sidebarPanel( sliderInput("bins", "Bins", 2, 20, 1, value = 10) ), mainPanel( fluidRow( uiOutput(

Shiny dynamic content based on window size (like css media query)

妖精的绣舞 提交于 2019-12-19 09:38:19
问题 I have some plots in a panel. I want to change them into tabsetpanel when the window width is small. Is there any way in shiny to determine window width of browser. For example, in the following example, how can I switch uiOutput from plotPanel1 to plotPanel2 when the window width is large enough. library(ggplot2) ui <- fluidPage( title = "TestApp", h1("Test Application"), sidebarLayout( sidebarPanel( sliderInput("bins", "Bins", 2, 20, 1, value = 10) ), mainPanel( fluidRow( uiOutput(

How to pass data from delegate method to the observable's onNext method in RxSwift?

放肆的年华 提交于 2019-12-18 09:53:30
问题 I have manager class which will connect and manage the data and state of the Bluetooth device. The manager class conforms to IWDeviceManagerDelegate and has a method which gives the weight data func onReceiveWeightData(_ device: IWDevice!, data: IWWeightData!) . Once I call listenToWeight() from any controller I want to give the data using Observable. How I fire an onNext event with the data of onReceiveWeightData method to listenToWeight observable? Below is the code. class