reactivex

RxJS groupBy and combineAll operators seem to omit output

不打扰是莪最后的温柔 提交于 2019-12-11 13:56:11
问题 When grouping output with the combination of .groupBy and .concatAll, some expected output is not generated. Sample code: var Rx = require('rx'); var source = Rx.Observable.from(['a1', 'a2', 'b1', 'b2', 'a3', 'a4', 'b3', 'b4']) .groupBy(function (item) { return item.substr(0, 1); }) .concatAll(); var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (err) { console.log('Error: %s', err); }, function () { console.log('Completed'); }); Actual output: $ node

Chaining dependent observables

空扰寡人 提交于 2019-12-11 06:30:45
问题 I need to create dependent API calls where the second one needs a value returned by the first one. First thing that comes to mind is using flatMap ApiManager.shared .createReport(report: report) .flatMap { (report) -> Observable<Report> in return ApiManager.shared.createReportStep(reportID: report.ID) } createReport returns Observable<Report> where after successfull call returns updated Report model(with ID), after that I need to call API to create report step, where report.ID is needed.

When should I use blockingGet?

て烟熏妆下的殇ゞ 提交于 2019-12-11 06:07:42
问题 I am using RxJava a lot for work and seen some examples of calling a method which returns an Observable or Single and then calling blockingGet on it to use the results in a different . I was thinking this might be a misuse of the library and the concept but I might be wrong. I will give a small example: public Observable<String> getStrings(){ // return sg } public Observable<String> getNames(){ // return names } public Observable<String> filterNamesInStrings() { List<String> names = getNames(

RxJava Observable minimum execution time

跟風遠走 提交于 2019-12-10 17:45:48
问题 I have an Observable (which obtains data from network). The problem is that observable can be fast or slow depending on network conditions. I show progress widget, when observable is executing, and hide it when observable completes. When the network is fast - progress flikers (appears and disappears). I want to set minimum execution time of observable to 1 second. How can I do that? "Delay" operator is not an option because it will delay even for slow network. 回答1: You can use Observable.zip(

RxSwift + MVVM + Coordinator Pattern, How to wait for coordinator result sequentially?

假装没事ソ 提交于 2019-12-10 10:45:52
问题 Scenario: I have base coordinator which basically like so: class Coordinator<Result> { // some coordinator class codes func coordinate(to: Coordinator<T>) -> Observable<T> { return coordinator.start() } func start() -> Observable<Result> { // return result } } and TestCoodinator1, TestCoordinator2, TestCoodinator3 like so: enum Status { case .success(data: NSData?) case .cancelled(error: NSError?) case .failed(data: NSData?) } class TestCoordinator1: Coordinator<Status> { // Init pass

How do I conditionally buffer key input based on event in RxJs

∥☆過路亽.° 提交于 2019-12-08 14:22:40
I'm pretty new to RxJs and haven't read a solution to this. More detailed explanation is in the comments, but basically I want to process a key combination (I think buffer would do this) when a specific key is pressed (like pressing "o" will wait for a short time for other keys to be pressed), but immediately process the key input otherwise (anything other than "o" if "o" hasn't been pressed, or the 'timeout' for "o" has passed). Observable.fromEvent(document, 'keydown') // Now I want to only continue processing the event if the user pressed "o99" in series, // as in pressed "o", followed by

Combination of RxJava and RxAndroid?

好久不见. 提交于 2019-12-08 07:42:49
问题 My Scenario is very similar to this Image: Flow of the app will be like this: View needs to get updated. Create an observable using RxAndroid to fetch the data from cache / local file. update the view. Make another network call using Retrofit and RxJava to update the view again with new data coming from the web services. Update the local file with the new data. So, I am updating the view twice(One from local file and just after that through webservices) How can I achieve the result using

How do I conditionally buffer key input based on event in RxJs

回眸只為那壹抹淺笑 提交于 2019-12-08 06:46:26
问题 I'm pretty new to RxJs and haven't read a solution to this. More detailed explanation is in the comments, but basically I want to process a key combination (I think buffer would do this) when a specific key is pressed (like pressing "o" will wait for a short time for other keys to be pressed), but immediately process the key input otherwise (anything other than "o" if "o" hasn't been pressed, or the 'timeout' for "o" has passed). Observable.fromEvent(document, 'keydown') // Now I want to only

Avoid passing data through multiple child components and caching redundant data in Angular 2

牧云@^-^@ 提交于 2019-12-08 06:13:55
问题 As far as I understood, there are 2 ways of distributing my data from external asynchronous web API calls to my components: Passing it from root element to my nested child components Through method calls from a service I have a root app component with some dynamically created divs that are showing content and controls to switch back and forward to see different data. That forward and backward switching is implemented by an index number that my controls are controlling. My first approach was

RxJS not all Subscribers receive all events

Deadly 提交于 2019-12-07 20:03:59
问题 I'm working on an exercise about RxJS. And there's something very strange happening: typoStream.subscribe(x => console.log('wont get executed')); wordCompletedStream.subscribe(nextStream); typoStream.subscribe(x => console.log('will get executed')); When the application runs the first console.log won't get printed and the second one will. Regardless of what the streams are and how they interact - this should never happen, right? Why is it important when I subscribe to an observable - shouldn