reactive-programming

How to use Micrometer Timer to record duration of async method (returns Mono or Flux)

做~自己de王妃 提交于 2020-01-14 10:11:18
问题 I'd like to use Micrometer to record the execution time of an async method when it eventually happens. Is there a recommended way to do this? Example: Kafka Replying Template. I want to record the time it takes to actually execute the sendAndReceive call (sends a message on a request topic and receives a response on a reply topic). public Mono<String> sendRequest(Mono<String> request) { return request .map(r -> new ProducerRecord<String, String>(requestsTopic, r)) .map(pr -> { pr.headers()

RxJava: Feed one stream (Observable) as the input of another stream

巧了我就是萌 提交于 2020-01-14 03:03:08
问题 I'm still learning RxJava. What is the best way to use a stream within another stream? Or is it against the principles of reactive programming? A toy example that I'm trying to write includes a TCP client and a server that sends back capitalized input. I'd like to take input from standard input, send it to the server and print out everything received by both the client and the server. The following is the expected output from the program: (User input) apple Server received: apple Client

Using rx.js, how do I emit a memoized result from an existing observable sequence on a timer?

梦想的初衷 提交于 2020-01-13 19:27:08
问题 I'm currently teaching myself reactive programming with rxjs, and I've set myself a challenge of creating an observable stream which will always emit the same result to a subscriber no matter what. I've memoized the creation of an HTTP "GET" stream given a specific URL, and I'm trying to act on that stream every two seconds, with the outcome being that for each tick of the timer, I'll extract a cached/memoized HTTP result from the original stream. import superagent from 'superagent'; import _

Setting iframe height to scrollHeight in ReactJS

江枫思渺然 提交于 2020-01-13 09:09:48
问题 The typical solution to the problem doesn't work in in React due to its dynamically generated component structure and event model, as opposed to traditional static HTML: script: <script> function resizeIframe(obj) { obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; } </script> html: <iframe src="..." frameborder="0" scrolling="no" onload="resizeIframe(this)" /> There is a npm package react-iframe , but it looks unfinished (accepts only props url , width , height ): https

Keyboard shortcuts to trigger reactive flows in R Shiny?

青春壹個敷衍的年華 提交于 2020-01-13 07:16:11
问题 Is it possible to have, say, F7 or Q trigger a reactive flow in a Shiny app (in Windows)? This question provides code for alternating tabs with keyboard input, but I am interested in starting reactive flows. For example, a button is 'triggered' every time the user presses Q in the keyboard. 回答1: Here's an example based on this answer: library(shiny) runApp(shinyApp( ui = fluidPage( tags$script(HTML("$(function(){ $(document).keyup(function(e) { if (e.which == 81) { $('#button').click() } });

Confused about diagrams of Yampa switches

↘锁芯ラ 提交于 2020-01-12 09:53:07
问题 There is some diagrams of Yampa switches at: http://www.haskell.org/haskellwiki/Yampa/switch http://www.haskell.org/haskellwiki/Yampa/rSwitch http://www.haskell.org/haskellwiki/Yampa/kSwitch (and so on). I've found that the switch , the only one diagram with description, is the easiest one to get understand. The others seems hard to follow the similar symbols to read the diagrams. For example, to try to read the rSwitch with the symbols used in the switch may be: Be a recursive SF which is

Why should we use Behavior in FRP

五迷三道 提交于 2020-01-12 07:17:27
问题 I am learning reactive-banana. In order to understand the library I have decide to implement a dummy application that would increase a counter whenever someone pushes a button. The UI library I am using is Gtk but that is not relevant for the explanation. Here is the very simple implementation that I have come up with: import Graphics.UI.Gtk import Reactive.Banana import Reactive.Banana.Frameworks makeNetworkDescription addEvent = do eClick <- fromAddHandler addEvent reactimate $ (putStrLn .

Reactive input from renderDataTable

人走茶凉 提交于 2020-01-12 04:50:06
问题 UPDATE (18-Dec-2015) The currest best apporach for this problem is here: Get Selected Row From DataTable in Shiny App ====================== I am trying to reactively re-display a dataset using a row selection provided by the user. As a toy example, ui.R library(shiny) shinyUI(pageWithSidebar( headerPanel('Examples of DataTables'), sidebarPanel( checkboxGroupInput('show_vars', 'Columns to show:', names(mtcars), selected = names(mtcars)) ), mainPanel( dataTableOutput("mytable") ) ) ) server.R

refactor fat arrow nested rxjs stream

随声附和 提交于 2020-01-11 13:47:22
问题 I am playing with http://reactivex.io/learnrx/. In better effort to learn rxjs. The array that I am working through is below. I am just trying to get the id's out of the array. I am able to get the answer to work but feel that answer could be better written. var movieLists = [ { name: "New Releases", videos: [ { "id": 70111470, "title": "Die Hard", "boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.jpg", "uri": "http://api.netflix.com/catalog/titles/movies/70111470", "rating": 4.0,

How to ensure that all observers see the same result from multiple parallel subscription

℡╲_俬逩灬. 提交于 2020-01-11 13:15:10
问题 I have two observables. First - get session from internet or from cache; Observable<SessionKey> getSession = getSessionFromInternetOrCache(); Second - call to server api, using session Observable<MyResult> apiCall = getSession.flatMap(session -> { return myApi.getResult(session); }) Problem, that I have several independent components (gui). They are starting in parallel. apiCall also started in parallel. And i gets several session keys. What behavior I want: getSessions should calling once,