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
11
votes
6 answers

How to debug Observable values in Angular2 / Typescript?

I have followed the tutorial for angular 2 and have a search functionality that renders a list of heroes asynchronously.
{{hero.name}}
In the component I have observable heroes: heroes:…
Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207
11
votes
1 answer

@reactivex/rxjs and rxjs NPM packages for RxJS 5

In @reactivex/rxjs package it is suggested that scoped package should be used: npm install @reactivex/rxjs And UMD module is available through npmcdn as https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.7/dist/global/Rx.umd.js However, unscoped rxjs…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
11
votes
3 answers

How to catch an error on a Request, then open a modal, then retry when modal closes with RxJS

I want to make a call to a server that can return an authorization fail (401) with Angular2's HTTP class. The flow of the request should look like that: The user makes a request to the server with myService.getSomething().subscribe() If the server…
Jean-Philippe Leclerc
  • 6,713
  • 5
  • 43
  • 66
11
votes
2 answers

Angular 2 polling with RxJS

I'm trying to poll a RESTful endpoint to refresh my live chat messages. I know the best approach for a live chat would be Websockets, I'm just trying to understand how RxJS works with Angular 2. I want to check for new messages every second. I have…
AndreFeijo
  • 10,044
  • 7
  • 34
  • 64
10
votes
2 answers

rxjs: Observable.of(...).delay is not a function

I would like to create a delayed observable in typescript by: import 'rxjs/add/observable/of'; ... const o = Observable.of(values).delay(10000); o.subscribe((v) => { alert(v); }); but I got the following error:…
Dániel Kis
  • 2,341
  • 5
  • 28
  • 51
10
votes
3 answers

Right way to upgrade RxJS to latest version?

When trying to install the latest version of RxJS, I used npm install rxjs as explained in this documentation: https://github.com/reactivex/rxjs But I got these warnings: npm warn @angular/common@5.1.0 requires a peer of rxjs@^5.5.0 but none is…
HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
10
votes
1 answer

Observable .catch is not a function

I get this very annoying error when running my code from a unix environment. This works fine when I run the code locally through ng serve, But when I deploy the code to my server, this error halts all program execution: ERROR TypeError:…
Øystein Amundsen
  • 3,993
  • 8
  • 44
  • 63
10
votes
3 answers

Can't make debounceTime() or throttleTime() to work on an Angular http request

For the life of me, I can not make this work. I've searched and searched, but I couldn't find any example (all examples out there are with .fromEvent(), none on a http.get). In my template, I have this input:
MrCroft
  • 3,049
  • 2
  • 34
  • 50
10
votes
1 answer

"Unsubscribe" function callback/hook in Observable "executor" function

I am confused about what the purpose of the "dispose" or "unsubscribe" function is for, which is (optionally) returned from an observable "executor" function, like so: const Rx = require('rxjs'); const obs = Rx.Observable.create(obs => { // we…
user5047085
10
votes
2 answers

Wait for a promise to resolve with RxJs

I'm trying to implement a "save on type" feature for a form using RxJS v5 beta. The data should be posted to the backend as the user types into the text fields. I'm creating a Rx.Subject to fire new events (next()) for new user input and post it…
Stefan
  • 14,530
  • 4
  • 55
  • 62
10
votes
2 answers

getting rxjs errors when referencing latest rxjs

I am using this tutorial https://egghead.io/lessons/rxjs-creating-an-observable which is referencing 2.5.2 rxjs version. I am referencing the latest rx.umd.js from rxjs@5.0.0-beta.6" npm package
Sergino
  • 10,128
  • 30
  • 98
  • 159
9
votes
1 answer

How would I use `do` as an RxJS lettable operator?

RxJS 5.5 allows grabbing lettable operators and piping them like so: import { ajax } from 'rxjs/observable/dom/ajax' import { catchError, map, retry } from 'rxjs/operators' ajax.getJSON('https://example.com/api/test') .pipe( retry(3, 1000), …
Kevin Ghadyani
  • 6,829
  • 6
  • 44
  • 62
9
votes
5 answers

Testing and mocking lettable operators in RxJS 5.5

Before lettable operator, I did a helper to modify debounceTime method, so it uses a TestScheduler: export function mockDebounceTime( scheduler: TestScheduler, overrideTime: number, ): void { const originalDebounce =…
Guillaume Nury
  • 373
  • 3
  • 7
9
votes
3 answers

How to watch object changes with rxjs 5

I would like to watch over an object, so all the subscribers will be informed for any changes of it. I saw it already been asked before, yet the answer is irrelevant since RXjs verion 5 do not include the ofObjectChanges in it's API anymore. I've…
yuval.bl
  • 4,890
  • 3
  • 17
  • 31
9
votes
3 answers

Angular client of Spring Boot 2 Reactor Flux API

How do I create an Angular 4 client for a Java Project Reactor reactive Flux API? The sample below has two APIs: a Mono API; and, Flux API. Both work from curl; but in Angular 4 (4.1.2) only the Mono API works; any ideas how to get Angular 4 to work…
Jan Nielsen
  • 10,892
  • 14
  • 65
  • 119