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
19
votes
3 answers

Rxjs 5 - Simple Ajax Request

I'm trying to get the value from a simple ajax request, but I don't understand how to do that. Here is the code: Rx.Observable .ajax({ url: 'https://jsonplaceholder.typicode.com/posts', method: 'GET', responseType: 'json' }) …
Mark
  • 1,603
  • 3
  • 13
  • 18
19
votes
2 answers

How to debug rxjs5?

On RxJS - Goals I read that their goal is better debuggability: Goals Provide more debuggable call stacks than preceding versions of RxJS I have just started to use redux-observable which is quite easier for me to understand comparing it to…
Amio.io
  • 20,677
  • 15
  • 82
  • 117
18
votes
2 answers

Convert Promise to RxJs Observable

Can someone help to convert this promise to an RxJs observable? I want to get token from local storage and if error,it should be catched with observer that subscribed to observable. Below is existing solution with Promise: getToken(): Promise
Vugar Abdullayev
  • 1,852
  • 3
  • 21
  • 46
18
votes
4 answers

Error rxjs_Observable__.Observable.forkJoin is not a function?

I am using Rxjs in an angualr-cli application. in viewer.component.ts //Other Imports import { Observable } from 'rxjs/Observable'; //omitting for brevity export class ViewerComponent implements OnInit, AfterViewInit, OnDestroy { …
Ankesh
  • 4,847
  • 4
  • 38
  • 76
18
votes
4 answers

How can I use RxJS to generate a requestAnimationFrame loop?

My goal is to create an animation loop à la requestAnimationFrame so that I could do something like this: animationObservable.subscribe(() => { // drawing code here }); I tried this code as a basic test: let x = 0; Rx.Observable .of(0) …
Kendall Frey
  • 43,130
  • 20
  • 110
  • 148
18
votes
3 answers

"async" pipe not rendering the stream updates

Trying to render the window size on window resize through a stream in an angular 2 component utilizing an async pipe:

Size: {{size$ | async | json}}

const windowSize$ = new BehaviorSubject(getWindowSize()); Observable.fromEvent(window,…
Daniel Birowsky Popeski
  • 8,752
  • 12
  • 60
  • 125
16
votes
1 answer

How to handle multiple action types in one epic? Any cons of doing the same?

Pretty new to redux-observables, rxjs and observables. Wanted to know how can I handle another action, say 'ActionTwo' in the same epic const Epic1 = (action$,store) => { return action$.ofType('ActionOne') .mergeMap((action) => { return…
Ajinkya Salve
  • 213
  • 1
  • 2
  • 6
16
votes
4 answers

How to tell the version number of RxJS

How to tell the version of the installed RxJS from the code? For example: var Rx = require('rxjs/Rx'); console.log(Rx.rev); // undefined console.log(Rx.version); // undefined Second question: How to tell if it's rxjs5 ?
Sohail Si
  • 2,750
  • 2
  • 22
  • 36
16
votes
1 answer

RxJS Polling for row updates on infinite scroll

I was watching Matthew Podwysocki event on https://www.youtube.com/watch?v=zlERo_JMGCw 29:38 Where he explains how they solved scroll on netflix. Where user scroll for more data as previous data gets cleaned up and more adds up (but scroll back…
Basit
  • 16,316
  • 31
  • 93
  • 154
15
votes
1 answer

error TS2339: Property 'takeUntil' does not exist on type 'Observable' and other rxjs v.6 errors

I just recently updated A LOT of packages in my angular project. Old package.json: { "name": "data-jitsu", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng…
Atticus29
  • 4,190
  • 18
  • 47
  • 84
15
votes
2 answers

Use fetch instead of ajax with redux-observable

In redux-observable is it possible to use isomporphic-fetch instead of Rx.DOM.ajax?
Amio.io
  • 20,677
  • 15
  • 82
  • 117
15
votes
1 answer

How to use Rx.Observable.prototype.let operator?

The example and explanation of the let operator (https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/let.md) is not clear. Anyone has a good example/explanation how the let operator works, and when we should use it?
Tuong Le
  • 18,533
  • 11
  • 50
  • 44
15
votes
1 answer

How to manage state without using Subject or imperative manipulation in a simple RxJS example?

I have been experimenting with RxJS for two weeks now, and although I love it in principle I just cannot seem to find and implement the correct pattern for managing state. All articles and questions appear to agree: Subject should be avoided where…
brokenalarms
  • 305
  • 3
  • 9
14
votes
1 answer

Why does piping a BehaviorSubject create an AnonymousSubject in RxJS?

When creating an RxJS BehaviorSubject, it stays a BehaviorSubject until it's pipe'd. As soon a pipe'd version is returned, it becomes an AnonymousSubject. Examples: // Instance of `BehaviorSubject` const behaviorSubject$ = new BehaviorSubject({…
Kevin Ghadyani
  • 6,829
  • 6
  • 44
  • 62
14
votes
1 answer

Should rxjs subjects be public in the class?

Let's say I have two classes, where you can observe over some observables. First example, with public subject: class EventsPub { public readonly onEnd = new Subject(); } Second example, with private subject and registering method: class…