Questions tagged [rxjs5]

The 5th version of the reactive extensions for javascript.

This tag is for questions regarding the 5th version of the ReactiveX framework for the JavaScript language.

Basics

RxJS is a framework for Observables. Observables are similar to Promises, in that they represent data, that may not jet be available. The difference is, that Observables can get multiple results (they are said to observe multiple events). These events could be anything, like clicks on a button, or network requests.

RxJS

rxjs provides an API for working with Observables in JavaScript. It has many methods, that allow modifying Observables, similar to how map(), filter() and reduce() work on ES6 Arrays.

Links

Before asking an rxjs5 question here on StackOverflow, please make sure to read the official documentation.

1510 questions
12
votes
4 answers

Is there any way to check if source is subscribed?

Just as the title says, in Angular 2, is there any way to check if source is already subscribed? Because I have to check it before using this.subscription.unsubscribe(); This is my code: this.Source = Rx.Observable.timer(startTime,…
user8090896
12
votes
2 answers

RXJS 5 .subscribe() without arguments

So a quick question. I've been using RxJS 5 for a few months now, and I've run into a bit of behavior that I don't really understand, as I haven't been able to look it up anywhere. I'm in a situation where subscribing to an observable chain with…
DarkNeuron
  • 7,981
  • 2
  • 43
  • 48
12
votes
2 answers

Creating an Observable using startWith from an Observable

I'm filtering an Observable with the input of another Observable - the input for the filtering comes from the user. The filtering is done with the RxJS operator combineLatest. Using this means that when subscribing to this stream, no values are…
Graham Laming
  • 1,213
  • 3
  • 14
  • 20
12
votes
2 answers

Complete callback in Observable.prototype.subscribe in Angular 2

The complete callback does not work as expected. Let me explain: See this picture, note the complete callback in subscribe method. This complete function is only called when the observerOrNext is called. When some error happens, the complete is not…
Marcos Kubis
  • 485
  • 1
  • 4
  • 11
12
votes
3 answers

Using RxJs and Angular 2 in order to deal with server-sent events

I am trying to display server-sent events emitted values in an angular 2 /RxJs app. The backend regularly sends individual strings to the client through server-sent events. I am not sure how to deal with the retrieved values on the angular 2/RxJs…
balteo
  • 23,602
  • 63
  • 219
  • 412
11
votes
1 answer

CombineLatest first event not firing

I want to know when my application goes offline and comes back online. I have the following events registered in rxjs: const online = Rx.Observable.fromEvent(window, 'online'); const offline = Rx.Observable.fromEvent(window, 'offline'); const…
Dieterg
  • 16,118
  • 3
  • 30
  • 49
11
votes
2 answers

RXJS: TypeError: this._subscribe is not a function

I'm migrating an ionic 3.8 app to 3.9.2. This migration includes an update to RXJS 5.5 I'm now experiencing this error: TypeError: this._subscribe is not a function. (In 'this._subscribe(sink)', 'this._subscribe' is an instance of t) After hours of…
tmuecksch
  • 6,222
  • 6
  • 40
  • 61
11
votes
2 answers

Operator that skips the next emission from the source whenever another Observable emits

I have a use case where I need an Observable to skip its next emission whenever another notifier Observable emits. source: |---X---X---X---X---X---X---X---X---X---X--|> notifier: |-------------X---------X----------X-------|> result: …
Brendon Roberto
  • 428
  • 3
  • 12
11
votes
1 answer

How to wait for guards in Angular

If i specify three guards on a route, it seems as though all guards are evaluated immediately. {path: '', component: OptionsComponent, canActivate: [ GuardOne, GuardTwo, GuardThree]} The problem I have is I don't want GuardTwo to run until GuardOne…
Thomas Maddocks
  • 1,355
  • 9
  • 24
11
votes
1 answer

RxJS Interval without delay

The following code emits an int after 5000ms and then another in every 5000ms later: let evens = Observable.interval(5000) .map(i => { return i * 2; }); evens.subscribe((i) => { console.log(i); }); Is it possible to do…
gunwin
  • 4,578
  • 5
  • 37
  • 59
11
votes
2 answers

Combine RxJS operators into new operator using TypeScript

I frequently find my self adding the same sequence of operators to observables, e.g. observable$ .do(x => console.log('some text', x)) .publishReplay() .refCount(); I'm looking for a way to combine these 3 operators in a small reusable…
Peter Albert
  • 16,917
  • 5
  • 64
  • 88
11
votes
5 answers

How do I adjust timeout duration on retry using RxJS?

I'm working with the latest Angular and Typescript and RxJS 5. Angular has currently made RxJS a necessity. I've used C# primarily for over 10 years and I'm very much used to Linq/Lambdas/fluent syntax which I assume formed the basis of Reactive. I…
Brandon
  • 984
  • 1
  • 11
  • 26
11
votes
2 answers

The right way to test rxjs

I brought the book "rxjs in action" and just finish the testing section. Testing rxjs codes are different then usual testing, because everything are lazy loading. In the book, they mention two test method, either passing done(I am using QUnit and…
softshipper
  • 32,463
  • 51
  • 192
  • 400
11
votes
3 answers

Angular and RxJS imports

I've always known to import my Observable operators separately to limit the load times. However I've noticed something today that I hope someone could please explain to me. I am using IntelliJ/WebStorm with Webpack. Let's say on a page in my…
Thibs
  • 8,058
  • 13
  • 54
  • 85
11
votes
3 answers

Unsubscribe from RxJS Observables

I have these two objects, and I want to stop listening to their events. I am totally new to observables and RxJS and just trying to work with the Inquirer library. Here is the RxJS API for…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817