rxjs

RxJS5 TypeScript typings fail

折月煮酒 提交于 2019-12-08 07:21:02
问题 I run tsc on my project, and I get these errors relating to the RxJS5 lib: $ tsc node_modules/rxjs/observable/FromEventObservable.d.ts(11,39): error TS2304: Cannot find name 'EventTarget'. node_modules/rxjs/observable/FromEventObservable.d.ts(11,103): error TS2304: Cannot find name 'NodeList'. node_modules/rxjs/observable/FromEventObservable.d.ts(11,114): error TS2304: Cannot find name 'HTMLCollection'. node_modules/rxjs/observable/dom/AjaxObservable.d.ts(16,23): error TS2304: Cannot find

Is there a better way to “join” data using Horizon?

丶灬走出姿态 提交于 2019-12-08 06:56:48
问题 My data looks something like this in RethinkDb: [appointments] { id: 1, date: "2016-01-01", stylistId: 1, } [stylists] { id: 1, name: "Sue", } On the client, I want to fetch an appointment and have the stylist embedded in the appointment object like so: { id: 1, date: "2016-01-01", stylist: { id: 1, name: "Sue", } } I can achieve something close using this query: return this.hz('appointments') .find(appointmentId) .fetch() .toPromise() .then(appointment => { return this.hz('stylists').find

dispatch multiple actions with redux-observable

我只是一个虾纸丫 提交于 2019-12-08 06:56:42
问题 After the user clicks the login button on a form, I want to dispatch an action which will trigger a spinner on the form while the request completes. I've tried the solution posted on this question but I'm getting an error redux-observable dispatch actions Here is the action that's dispatched when the user clicks on the login button: dispatch(startLoginEpic({ login: loginData, from })); Here is my epic: const LoginEpic = (action$, state$) => action$.pipe( ofType(types.START_LOGIN_EPIC), // map

Unsubscribe on subject in RxJS

怎甘沉沦 提交于 2019-12-08 06:54:46
问题 I found following construct a bit confusing for me (example provided in typescript): let someSubject: Subject<any> = new Subject(); let subscription1: Subscription = someSubject.subscribe((v) => {console.log(v)}) let subscription2: Subscription = someSubject.subscribe((v) => {console.log(v)}) Its obvious that I can (and should) unsubscribe from pending subscription like so: subscription1.unsubscribe(); subscription2.unsubscribe(); But the Subject class do have a member method unsubscribe . It

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

In Rxjs scan operator, is it possible to remove an item from the internal accumulator created by the scan operator?

我的未来我决定 提交于 2019-12-08 06:44:46
问题 Based on this question here, I am using the Rxjs scan operator to keep track of all of the observables that get emitted in an the accumulator array, and then each new incoming value I am adding it to that internal accumulator array created by the scan operator and then I am emitting the single array. This allows me to bind to that array observable with the async pipe in the template and display previews of images user uploaded. However if I want to implement the remove or undo functionality,

Resubscribe to takeUntil/skipUntil

馋奶兔 提交于 2019-12-08 06:31:44
问题 The following code defines behavior i want (it works). Emmition of mousemove event occur only when mouse down. Rx.Observable.fromEvent(window,"mouseup") .subscribe( () => { if(subscription) subscription.dispose(); } ) Rx.Observable.fromEvent(window,"mousedown") .subscribe( () => { subscription = Rx.Observable.fromEvent(window,"mousemove") .subscribe( (event) => console.log(event) ) } ) I want to rewrite it using takeUntil/skipUntil operators. But this fails: let fs = [ (e) => console.log(e),

rxjs rate limit (requests per second) and concurrency

血红的双手。 提交于 2019-12-08 06:01:49
问题 I am trying to figure out how to write a rate limiter in rxjs. Used to access most apis (twitter, facebook, etc) If not supported by out of the box methods, i would assume a scheduler could be written. For instance highland.js has ratelimit. I don't want to drop any items like with window, sample, etc. var source = Rx.Observable.create(function (observer) { // queue of requests _.each(requests, function(r) { observer.onNext(r); }); observer.onCompleted(); // Any cleanup logic might go here

Combining Observables when both change simultaneously

左心房为你撑大大i 提交于 2019-12-08 05:44:32
问题 I am trying to integrate ReactiveX into my GUI using RxPY. This is a general ReactiveX question. Say I have a visualization that depends on multiple Observable streams using combine_latest(stream1, stream2, plot_function) . This works great when one Observable changes, like when the user modifies a value; the visualization updates using the new values. However, sometimes both Observables are updated simultaneously, like when the user loads data for both streams from a single file. Technically

Multiple HTTP Requests with RxJS, with parameters

倖福魔咒の 提交于 2019-12-08 05:25:02
问题 I call this api https://jokerleb.com/wp-json/wp/v2/ads/ I grab the id of each ad and then I append it to this url https://jokerleb.com/wp-json/wp/v2/media?parent=24385 My code is loadAds() { let i = 0; this.HttpClient.get(ENV.site_url + ENV.ads_url) .subscribe(res => { this.ads = this.ads.concat(res); this.HttpClient.get(ENV.site_url + ENV.ads_thumb_url + this.ads[i].id + "&&ads/" + this.ads[i].id) .subscribe(res => { this.items = this.items.concat(res); console.log(ENV.site_url + ENV.ads