reactive-programming

RxJS: Splitting an array result from Observable.fromPromise

为君一笑 提交于 2019-12-19 14:37:52
问题 I'm using RxJS here and I can't seem to get over this seemingly simple issue. rx.Observable .from([1,2,3,54,3,22,323,23,11,2]) .distinct() .subscribe(function next (x) { console.log('Next'); console.log(x); }, function error (x) { console.log('Error'); console.log(x); }, function completed () { console.log('Completed'); }); The above code spits out each array item in order as expected. rx.Observable .fromPromise(getNumbers([1,2,3,54,3,22,323,23,11,2])) .distinct() .subscribe(function next (x)

Creating Multiple Timers with Reactive Extensions

我只是一个虾纸丫 提交于 2019-12-19 11:02:24
问题 I've got a very simple class that I am using to poll a directory for new files. It's got the location, a time to start monitoring that location, and an interval (in hours) for when to check again: public class Thing { public string Name {get; set;} public Uri Uri { get; set;} public DateTimeOffset StartTime {get; set;} public double Interval {get; set;} } I am new to Reactive Extensions, but I think it is exactly the right tool for the job here. At the start time, and on every subsequent

Retrieving reactive dependencies as inferred by shiny::reactive()

点点圈 提交于 2019-12-19 09:00:40
问题 Consider this presentation of Joe Cheng were he explains how he and his colleagues implemented the reactive framework in shiny (which is inspired by Meteor): Actual question Could someone explain to me how I would go about finding out about a reactive object's dependencies (i.e. listing their names and environments, actually accessing them, etc.) that have been automatically inferred by shiny::reactive() ? More specifically, I'd like to use that information in my custom "one-stop-shop"

Creating a reactive dataframe with shiny apps

无人久伴 提交于 2019-12-19 08:42:52
问题 I am trying to get this reactive to return a data frame that I can manipulate with plotly. avghour <- reactive({ result <- data.frame() start_date <- as.numeric(unlist(input$i6[1])) end_date <- as.numeric(unlist(input$i6[2])) mkw <- maxkwpeakdates[(maxkwpeakdates >= start_date & maxkwpeakdates <= end_date) & !is.na(maxkwpeakdates), ] mkw <- na.omit(mkw) mopkw <- maxonpeakkwdates[(maxonpeakkwdates >= x & maxonpeakkwdates <= y) & !is.na(maxonpeakkwdates), ] mopkw <- na.omit(mopkw) mkwhour <-

Creating a reactive dataframe with shiny apps

橙三吉。 提交于 2019-12-19 08:42:33
问题 I am trying to get this reactive to return a data frame that I can manipulate with plotly. avghour <- reactive({ result <- data.frame() start_date <- as.numeric(unlist(input$i6[1])) end_date <- as.numeric(unlist(input$i6[2])) mkw <- maxkwpeakdates[(maxkwpeakdates >= start_date & maxkwpeakdates <= end_date) & !is.na(maxkwpeakdates), ] mkw <- na.omit(mkw) mopkw <- maxonpeakkwdates[(maxonpeakkwdates >= x & maxonpeakkwdates <= y) & !is.na(maxonpeakkwdates), ] mopkw <- na.omit(mopkw) mkwhour <-

How can I use RxJs to hold off any requests for an AJAX call until the previous one resolves

非 Y 不嫁゛ 提交于 2019-12-19 06:45:32
问题 I have an observable that represents an action that is triggered by some outside component. For the purpose of this question, let's call it createBananaAction . I have a bananaService with a method create that performs an AJAX request and returns the created banana as a Promise . So, whenever some data arrives from the createBananaAction , we want to call bananaService.create() . The code looks like this: (using RxJs) this.createdBananas = createBananaAction.flatMap(() => bananaService.create

How can I use RxJs to hold off any requests for an AJAX call until the previous one resolves

血红的双手。 提交于 2019-12-19 06:43:46
问题 I have an observable that represents an action that is triggered by some outside component. For the purpose of this question, let's call it createBananaAction . I have a bananaService with a method create that performs an AJAX request and returns the created banana as a Promise . So, whenever some data arrives from the createBananaAction , we want to call bananaService.create() . The code looks like this: (using RxJs) this.createdBananas = createBananaAction.flatMap(() => bananaService.create

How to make RACSignal to become hot?

孤街浪徒 提交于 2019-12-19 03:38:23
问题 ReactiveCocoa can convert the signal to "hot" signal by calling its -subscribeCompleted: . But I think this method is quite verbose if you do not care about the result (i.e. no subscribers). RACDisposable *animationDisposable = [[self play:animation] subscribeCompleted:^{ // just to make the animation play }]; And these 3 lines are not expressive enough to show my intention. Is there any method for similar purpose? Thanks! 回答1: I want to do nothing except making it hot (=make it run once).

How to collect paginated API responses using spring boot WebClient?

核能气质少年 提交于 2019-12-18 16:55:31
问题 I have a paginated response from an URL, I want to keep on hitting the next page URL which I get from the previous response and keep on collecting items till I don't have a "nextPage" URL in my response. How to achieve this in a reactive way using spring boot WebClient from WebFlux with out blocking? Request1: GET /items response: { items: [...] nextPage: "/items?page=2" } Request2: GET /items?page=2 response: { items: [...] nextPage: "/items?page=3" } Request3: GET /items?page=3 response: {

Android Pros & Cons: Event Bus and RxJava

不打扰是莪最后的温柔 提交于 2019-12-18 11:40:09
问题 I have been using Event Bus in my apps (i.e: greenrobot/EventBus). But I find some disadvantages in using Event Bus: Chaining tasks execution is difficult A lot of classes to represent events Less clear code (well, it's still possible to trace, but not as clear) I have been researching for new techniques to deal with this problem. And I read quite a bit about RxJava and wonder if it could be a solution. So my questions about RxJava (based on what I have read recently): Could RxJava observer