reactive-programming

Spring 5 Reactive - WebExceptionHandler is not getting called

感情迁移 提交于 2019-12-06 15:23:16
I have tried all 3 solutions suggested in what is the right way to handle errors in spring-webflux , but WebExceptionHandler is not getting called. I am using Spring Boot 2.0.0.M7 . Github repo here @Configuration class RoutesConfiguration { @Autowired private lateinit var testService: TestService @Autowired private lateinit var globalErrorHandler: GlobalErrorHandler @Bean fun routerFunction(): RouterFunction<ServerResponse> = router { ("/test").nest { GET("/") { ServerResponse.ok().body(testService.test()) } } } } @Component class GlobalErrorHandler() : WebExceptionHandler { companion object

Observable.Retry doesn't work as expected

喜你入骨 提交于 2019-12-06 15:05:17
I have a sequence of numbers that are processed using an async method. I'm simulating a remote service call that may fail . In case of failure, I would like to retry until the call successes. The problem is that with the code I'm trying, every time an exception is thrown in the async method, the sequence seems to hang forever . You can test it with this simple code snippet (it's tested in LINQPad) Random rnd = new Random(); void Main() { var numbers = Enumerable.Range(1, 10).ToObservable(); var processed = numbers.SelectMany(n => Process(n).ToObservable().Retry()); processed.Subscribe( f =>

How to continue streaming items after error in RxJava?

送分小仙女□ 提交于 2019-12-06 15:03:46
I'm RxJava newbie, and I've got following problem. Say I have sequence of items and on of items propagates error, I want to ignore it and to continue processing other items. I have following snippet: Observable.from(Arrays.asList("1", "2", "3")) .map(x -> { if (x.equals("2")) { throw new NullPointerException(); } return x + "-"; }) .onExceptionResumeNext(Observable.empty()) .subscribe(System.out::println); I'm getting: 1- But I want to get: 1- , 3- How can I do that? the trick is to wrap the value, which would be transformed somehow, into a new observable and flatmap over it as in the

How to detect if a observable has not emitted any events for specific time in RxSwift

给你一囗甜甜゛ 提交于 2019-12-06 14:36:37
问题 I am trying to detect if a observable(my case button.rx.tap ) has not emitted any value for say like 3 seconds. If yes, I would like to update the user interface. Here is my attempt so far: Observable<Int>.interval(3, scheduler: MainScheduler.instance) .takeUntil(button.rx.tap) // I know take until will stop the timer sequence .subscribe({ event in print(event) UIView.animate(withDuration: 0.4, animations: { if let number = event.element { let scale: CGFloat = number % 2 == 0 ? 1.5 : 1.0 self

R Shiny Input Reactivity Error on Drag-and-Drop

拈花ヽ惹草 提交于 2019-12-06 12:28:35
问题 Im currently creating a R Shiny app with some custom js to provide drag and drop functionality. While the drag and drop works perfectly for a single file, when I reset it using shinyJS, uploading the same file again does not work properly. I understand that this is because the onchange function is not being triggerred with the file with the same name being re-inputted (regardless of if the file contents have been modified) JS: var datasets = {}; var dragOver = function(e) { e.preventDefault()

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

拥有回忆 提交于 2019-12-06 11:33: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 _ from 'lodash'; // Cached GET function, returning a stream that emits the HTTP response object var

How to buffer stream using fromWebSocket Subject

时间秒杀一切 提交于 2019-12-06 10:42:52
问题 This RxJava buffer example (with marble chart!) describes the desired result perfectly: collect items in buffers during the bursty periods and emit them at the end of each burst, by using the debounce operator to emit a buffer closing indicator to the buffer operator Edit: having reviewed How to create a RxJS buffer that groups elements in NodeJS but that does not rely on forever running interval?, my issue appears related to using a Subject as opposed to straight Observable . Using the

A build function returned null The offending widget is: StreamBuilder<Response>

喜欢而已 提交于 2019-12-06 07:34:35
I'm new to Flutter and I'm trying to accomplish a simple thing: I want to create a signup functionality using BLoC pattern and streams. For the UI part I have a stepper , that on the very last step should fire a request to the server with the collected data. I believe I have everything working until the StreamBuilder part. StreamBuilders are meant to return Widgets, however, in my case I don't need any widgets returned, if it's a success I want to navigate to the next screen, otherwise an error will be displayed in ModalBottomSheet. StreamBuilder is complaining that no widget is returned. Is

MeteorJS - Watch for server variable change and update the template value

点点圈 提交于 2019-12-06 05:28:38
问题 I have a doubt. Not sure if it's possible and didn't find a clear answer about it. Is it possible to add a "watcher" to a server variable so when the value changes, I can update the view (client side) ? Let say I have a var counter = 0 and a Timeout function which updates the counter variable every minute. I want to update a <span>{{counter}}</span> in the client side. I would need to add a "watcher" to this server variable and make it reactive. Thanks in advance! 回答1: The correct way to do

R Shiny Tabsets simultaneous processing

冷暖自知 提交于 2019-12-06 05:18:48
I have a R Shiny app, which calculates several statistics in different tabsets. As the calculations are quite computation intensive, I use submitButton to prevent reactivity. My problem is now that each calculation (all in different tabsets) are writing outputs to a folder and I want Shiny to write an output for all tabsets when initializing. Unfortunately, Shiny only creates an output for the tabset, that is active when initializing. Is there a way to tell Shiny , that it should calculate/render outputs for every tab when initializing? Here is a modified example from the Shiny [Tutorial]:(