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
0
votes
1 answer

TypeError: unknown type returned

I am using ngrx/effects. I got this error: ORIGINAL EXCEPTION: TypeError: unknown type returned This is part of my codes: this.store.dispatch({ type: CHAT_LOAD_MESSAGES, payload: chatId }); @Effect() loadMessages$ = this.updates$ …
Hongbo Miao
  • 45,290
  • 60
  • 174
  • 267
0
votes
1 answer

How to apply rxjs operator to data got from angularfire2

Suppose I requested for data in angularfire2 like this: var ref = new Firebase("firebase url"); Now how can I apply rxjs operator like map operator to the data coming
blackHawk
  • 6,047
  • 13
  • 57
  • 100
0
votes
1 answer

RxJS5 Mongo issue

I have some RxJS code using mongo to perform queries. Works fine in RxJS v4 but as I am migrating to v.5 I am running into issues. Here's some simplified code: // Get a mongo connection getDb() { var connect =…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
0
votes
1 answer

How to avoid overwriting event when productId is different?

I have a list of products. Each product has an id and description.
editStream: EventEmitter = new…
Hongbo Miao
  • 45,290
  • 60
  • 174
  • 267
0
votes
1 answer

How to set isSignedIn to true before Guard runs?

I am using ngrx/router. I have a LoginGuard, when I open a page which needs to login, the LoginGuard runs before isSignedIn is set to true. So at that time isSignedIn is undefined. @Injectable() export class LoginGuard implements Guard { …
Hongbo Miao
  • 45,290
  • 60
  • 174
  • 267
0
votes
1 answer

Keep delaying HTTP request until new params are arriving

Suppose we have a function getIds() which takes an array of some ids like this: getIds([4, 1, 32]); This function will delay HTTP call for 100ms. But during 100ms if this same function is called again: getIds([1, 8, 5]); It will reset the 100ms…
ifadey
  • 1,062
  • 10
  • 12
0
votes
1 answer

Why is my RxJS Observable completing right away?

I'm a bit new to RxJS and it is kicking my ass, so I hope someone can help! I'm using RxJS(5) on my express server to handle behaviour where I have to save a bunch of Document objects and then email each of them to their recepients. The code in my…
Johnny Ji
  • 169
  • 2
  • 11
0
votes
1 answer

Type 'Observable' is not assignable to type 'JSON' in angular2 with rxjs5

I want to change all of my EventEmitter to Subjects since it is the recommended way to share variables and states instead of emitting an event. But now I've got a problem and I just don't understand how to solve it. Here is the sample…
malachi54
  • 67
  • 1
  • 1
  • 5
0
votes
1 answer

rxjs5 get last emitted value upon subscription

Using rxjs 5, I want to subscribe to an observable and begin the stream with the last emitted value. The operator '.cache' is supposed to be built for this (I think) but I can't get it to work. I did a small test where fire an observable (by…
Brad Woods
  • 1,507
  • 2
  • 12
  • 30
0
votes
1 answer

RxJs alternate for if then else statement

What is the best way to write following code in RxJs. Assuming getSomethingFromDb( ) returns an observable. Note: I do not want to use IF from my RXJS code let something:any = getSomethingFromDatabsae( ) if(
ATHER
  • 3,254
  • 5
  • 40
  • 63
0
votes
1 answer

angular2 viewing observable with async pipe not rendering

I am using @ngrx/store and I am grabbing a slice of the state from the store. I have a component that wants to display that slice. However, with the {{ obs$ | async}} present in the template, the entire template is not rendered. If I remove the {{…
nathasm
  • 2,524
  • 5
  • 24
  • 35
0
votes
2 answers

Migration from Angular2 beta1 to Angular2 beta15 - .map() error

I'm trying to migrate a project from Angular2 beta1 to Angular2 beta15 and I have some issues. I have error message : 'map' property does not exists on 'Observable< Response >' Example of code with this error : import { Injectable } from…
AdrienTorris
  • 9,111
  • 9
  • 34
  • 52
0
votes
1 answer

Getting error when subscribing to promise

I am getting an error when page is getting loaded saying people.ts?9320:22 SyntaxError: Unexpected token <(…)PeopleComponent.apiService.people.subscribe.error @ people.ts? 9320:22SafeSubscriber.__tryOrUnsub @ VM38600:166SafeSubscriber.error @…
Sergino
  • 10,128
  • 30
  • 98
  • 159
0
votes
1 answer

Difference how to access the promise

Is there a difference between var source1 = Rx.Observable.of(42); const oneSubscription = source1.subscribe({ next: x => console.log(x) }); oneSubscription.unsubscribe(); and var source2 = Rx.Observable.of(42); source2.forEach(x =>…
Sergino
  • 10,128
  • 30
  • 98
  • 159
0
votes
2 answers

How to use Observables operators with EventEmitter (FormModel.valueChanges) in Angular2

I'm trying to use some simple operators on a EventEmitter (from a FormModel.valueChanges) but I don't know how it's suppose to be done. The class EventEmitter extends from Subject export declare class EventEmitter extends Subject so I tried…