rxjs5

rxjs5 - no WebSocket constructor can be found

穿精又带淫゛_ 提交于 2019-12-12 18:23:24
问题 I'm trying to do something basic, but it's completely eluding me. I'm trying to create an Observable from rxjx/observable/dom/webSocket in RxJS5, but I'm not using typescript, or es6 modules... just plain 'ole good commonJS. I've managed to patch the Observable properly according to the docs, but whenever I try to pass in the string expected for the subject, I get the error: no WebSocket constructor can be found , [source]. I haven't had time to dig into TypeScript yet, but from what I can

Using `retryWhen` in http requests

≡放荡痞女 提交于 2019-12-12 16:34:32
问题 I have extended Http class to set default headers and handle errors for all the requests inside an angular2 app, and I would like to use retryWhen() to retry the requests on certain errors. On which errors should retryWhen retry the request and on which errors should it stop? @Injectable() export class WpHttp extends Http { constructor(backend: ConnectionBackend, defaultOptions: RequestOptions, private wpService: WpService) { super(backend, defaultOptions); } get(endpoint: string, args?:

switchMap does not seem to complete when the inner observable completes

心不动则不痛 提交于 2019-12-12 11:21:55
问题 I'm still a noob when it comes to RxJS but here's a JSBin of what I am trying to do. https://jsbin.com/wusalibiyu/1/edit?js,console I have an observable 'a' (in my case it's the current active connection) which emits a new object whenever the connection reconnects. It's an observable itself because it can re-emit a new value. I now want an observable that completes whenever an action is executed on the current connection. That action notifies it is done when the observable for it completes.

How to use RxJs distinctUntilChanged?

一个人想着一个人 提交于 2019-12-12 09:29:29
问题 I'm getting started with RxJs (using the v5 beta), but somehow I can't figure out how to work with distinctUntilChanged . The output from the code below if I run it in babel-node is [ 'a', 1 ] { key: 'a', state: 1 } Next: { value: 42 } Completed That is not what I would expect. Why is only one entry passing distinctUntilChanged ? I would expect the output to be [ 'a', 1 ] [ 'a', 0 ] [ 'a', 1 ] { key: 'a', state: 1 } { key: 'a', state: 2 } { key: 'a', state: 0 } { key: 'a', state: 1 } Next: {

RXJS: Single Observable from dynamically created Observables

南笙酒味 提交于 2019-12-12 04:27:52
问题 I am trying to create an observable (fixedObservable here) which will be fed by multiple dynamically created observable over time. Whenever a subscription is made than the subscriber should get the most recent value from the fixedObservable. Although I have achieved it but I wanted to know if there is any simple solution to it. You can find the code here https://jsfiddle.net/dzm2t3pa/8/ . Thanks var resultdiv = document.getElementById('result'); function print(message) { var paraEl = document

finally() is not called when returning empty() in catch()

浪尽此生 提交于 2019-12-12 04:25:14
问题 I wrote a generic request method that is supposed to show a loading indicator while the request is running. If an error occurs (like 404), I display the message in .catch and then return Observable.empty() , so that the following code doesn't crash (since no data is returned). The big problem is that then .finally won't be called either. Is that a bug? Is there a workaround? Here's my code: res = Observable .of(true) .do(() => this.store.dispatch(new ShowLoadingIndicatorAction())) .switchMap(

Difference between RxJS5 subscription and observer

 ̄綄美尐妖づ 提交于 2019-12-12 03:58:55
问题 I see some question/answers relating to Rx Subscriptions/Observers but they may be for older versions of Rx and also not for RxJS, which may conform to a different API. I was under the impression that subscriptions/subscribers and observers were all the same. If you look at the docs, they are in different adjacent sections, but seem to be exactly the same: Observer: http://reactivex.io/rxjs/manual/overview.html#observer Subscription: http://reactivex.io/rxjs/manual/overview.html#subscription

Rxjs - Subscribing to interdependent observables

微笑、不失礼 提交于 2019-12-12 02:22:06
问题 I am learning angular 2 and rxjs. I have 3 variables, A B C. B depends on the value of A C depends on the value of A and B I am trying to setup up the observables such that: When A is updated, B and C will be auto updated. When B is updated, C will be auto updated. I tried two setups but they are not satisfactory. First setup: B subscribes observable A; C subscribes observable B withlatestfrom A. The changes in A did cascade down to B then to C but the value from A is not the latest. Second

RxJS Observable & Observer issues

亡梦爱人 提交于 2019-12-12 01:44:16
问题 I have an Angular 2 service that executes a few steps to authenticate and log in an app user. Any time I try to call next() on my Observer I get an error that it is undefined. The only place I can successfully call next() on it is inside contructor when the Observable is instantiated. If I call authenticateUser() I get an error that this.isLoggedIn is undefined. AuthService.ts public isLoggedIn$: Observable<boolean>; private isLoggedIn: Observer<boolean>; constructor(...) { this.isLoggedIn$ =

Postpone observable when other one fired in RxJs

梦想的初衷 提交于 2019-12-12 00:42:00
问题 I have a table on a page and two subscriptions: First one reloads table data. It has a delay because it calls an api. Second highlights data. Does not affect table data. When subscriptions fire one by one everything is OK, but when they fire at the same time data is highlighted and soon after is reloaded so highlighting is gone. You can see it here. Is there are way to postpone highlighting if reloading is in action? Probably I can accomplish this by introducing loading variable but I am