reactivex

Get one event per 1000 milliseconds interval

空扰寡人 提交于 2020-04-18 05:36:28
问题 I have infinite stream of events that can emit some consecutive event portions and I want to take one event per 1000 each milliseconds. I tried debounceTime / auditTime / throttleTime but they doesn't include all events I want - to demonstrate the behavior I created playground on stackblitz which fires events once per 300ms within portion of 10 events: debounceTime(1000) will give only event # 10 throttleTime(1000) will give events 1,5,9 but it will omit # 10 which is essential auditTime(1000

What are the differences between using a Subject and an Observable, and what are the uses for each?

扶醉桌前 提交于 2020-03-22 03:40:26
问题 I have learned of two different ways of making an Observable. First one was with a Subject, like so: // file A const message$ = new Subject(); // file B message$.subscribe( (message) => console.log(message) ); // file C message$.next("Hello there!"); This method of creating an Observable allows me to have a way to exchange data from file B to file C. The second way is via the Observable class, like so: // file A const click$ = new Observable( function(observer) { //Alternatively, I can use

Observe array in Swift 3 using RxSwift

梦想的初衷 提交于 2020-01-22 12:28:10
问题 To create an observable array using RxSwift in Swift 2, I use to do this: [1, 2, 3].toObservable().subscribeNext { print($0) } But in Swift 3, it doesn't work anymore, I got this error: Value of type '[Int]' has no member 'toObservable' How can I create an RxSwift observable array from a swift array? 回答1: In Swift 3 using RxSwift 3.0 I will do that like this: var array: Variable<[Int]> = Variable([1, 2, 3]) array.asObservable().subscribe(onNext: { updatedArray in print(updatedArray) }) array

RxJS vs rx-node

旧巷老猫 提交于 2020-01-05 04:21:42
问题 What's the difference between RxJS and rx-node? Why shouldn't I just use RxJS instead of rx-node in my NodeJS project? 回答1: The rx-node repository covers this in its first line: This project provides Reactive Extensions for JavaScript (RxJS) bindings for Node.js and io.js to abstract over the EventEmitter, Streams and more. RxJS is the official repository. rx-node adds support for a few node specific things, the details of which are outlined on their documentation page. If you need those

RxJava - “Only one emission is allowed to travel up the Observable chain at a time…”

我们两清 提交于 2020-01-04 09:48:17
问题 I'm reading a blog post here: http://tomstechnicalblog.blogspot.com/2016/02/rxjava-understanding-observeon-and.html where it is said that No matter what Scheduler you are subscribed on, only one emission is allowed to travel up the Observable chain of operators at a time. Below, you can observe that the emission must be pushed all the way from the source to the Subscriber before the next emission can start. Right above that quoted text is an example written as: public static void main(String[

Rate-limiting and count-limiting events in RxJS v5, but also allowing pass-through

烈酒焚心 提交于 2020-01-02 11:19:14
问题 I have a bunch of events to send up to a service. But the requests are rate limited and each request has a count limit: 1 request per second: bufferTime(1000) 100 event items per request: bufferCount(100) The problem is, I am not sure how to combine them in a way that makes sense. Allowing pass-through Complicating this further, I need to make sure that events go through instantaneously if we don't hit either limit. For example, I don't want it to actually wait for 100 event items before

Observing UITextField.editing with RxSwift

主宰稳场 提交于 2019-12-31 18:58:31
问题 I want to observe the property UITextfield.editing . I'm using this code: self.money.rx_observe(Bool.self, "editing").subscribeNext { (value) in print("") }.addDisposableTo(disposeBag) But in the process of running, it's only performed once. How do I solve this,please 回答1: Don't observe the editing property, because it's not just a stored property. It's defined as: public var editing: Bool { get } So you don't know how UIKit is actually getting that value. Instead, use rx.controlEvent and

Make Http call using ReactiveX for Java

若如初见. 提交于 2019-12-30 06:16:08
问题 I am new to ReactiveX for Java and I've the following code block that make external http call but it is not async. We are using rxjava 1.2, and Java 1.8 private ResponseEntity<String> callExternalUrl(String url, String json, HttpMethod method) { RestTemplate restTemplate; HttpEntity request; request = new HttpEntity(jsonContent, httpHeaders); return restTemplate.exchange(url, httpMethod, request, String.class); } I've the following code block I found online but I couldn't totally understand

How to wrap a cold observable (ReactiveX / RxJava) that always return the last result + allow refresh

江枫思渺然 提交于 2019-12-25 21:22:46
问题 I'm trying to rely on Reactive Programming to share the result of an http call with many subscribers. At the same time I want to be able to perform the call again (refresh). I start with a cold Observable that perform the http call and then immediately complete. I want to wrap it to obtain an hot observable that work like this: every subscriber should always receive the last event (if any) when subscribing and every other event until unsubscribed. I should have a way (external to that

How to use frokJoin of Observable with own event

你。 提交于 2019-12-24 17:47:59
问题 Im using Subject of reactivex in my angular2 app to signal event. When I do something like that: let subject1 = new Subject<string>(); let subject2 = new Subject<string>(); subject1.subscribe(data=>console.debug(data)); subject2.subscribe(data=>console.debug(data)); subject1.next("this is test event1"); subject2.next("this is test event2"); everything works fine, but I want to wait for both events to fire, then do some actions. I found Observable.forkJoin but I cant make it work with Subjects