Angular 2 beta.17: Property ‘map’ does not exist on type ‘Observable’

I just upgraded from Angular 2 beta16 to beta17, which in turn requires rxjs 5.0.0-beta.6. (Changelog here: https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta17-2016-04-28) In beta16 all was working well regarding Observable/map functionality. The following errors appeared after I upgraded and occur when typescript attempts to transpile: Property ‘map’ does not exist on type ‘Observable’ (anywhere where I’ve used map with … Read more

take(1) vs first()

I found a few implementation of AuthGuards that use take(1). In my project, I used first(). Do both work the same way? import ‘rxjs/add/operator/map’; import ‘rxjs/add/operator/first’; import { Observable } from ‘rxjs/Observable’; import { Injectable } from ‘@angular/core’; import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from ‘@angular/router’; import { AngularFire } from ‘angularfire2’; @Injectable() export … Read more

Subject vs BehaviorSubject vs ReplaySubject in Angular

I’ve been looking to understand those 3: Subject BehaviorSubject ReplaySubject I would like to use them and know when and why, what are the benefits of using them and although I’ve read the documentation, watched tutorials and searched google I’ve failed to make any sense of this. So what are their purpose? A real-world case … Read more

Create one-time subscription

I need to create a subscription to an Observable that is immediately disposed of when it is first called. Is there something like: observable.subscribeOnce(func); My use case, I am creating a subscription in an express route handler and the subscription is being called multiple times per request. 7 Answers 7

Subscribe is deprecated: Use an observer instead of an error callback

When I run the linter it says: subscribe is deprecated: Use an observer instead of an error callback Code from this angular app: this.userService.updateUser(data).pipe( tap(() => {bla bla bla}) ).subscribe( this.handleUpdateResponse.bind(this), this.handleError.bind(this) ); Don’t know exactly what should I use and how… Thanks! 8 Answers 8

Return an empty Observable

The function more() is supposed to return an Observable from a get request export class Collection { public more = (): Observable<Response> => { if (this.hasMore()) { return this.fetch(); } else { // return empty observable } }; private fetch = (): Observable<Response> => { return this.http.get(“some-url”).map((res) => { return res.json(); }); }; } In … Read more

How to get current value of RxJS Subject or Observable?

I have an Angular 2 service: import {Storage} from ‘./storage’; import {Injectable} from ‘angular2/core’; import {Subject} from ‘rxjs/Subject’; @Injectable() export class SessionStorage extends Storage { private _isLoggedInSource = new Subject<boolean>(); isLoggedIn = this._isLoggedInSource.asObservable(); constructor() { super(‘session’); } setIsLoggedIn(value: boolean) { this.setItem(‘_isLoggedIn’, value, () => { this._isLoggedInSource.next(value); }); } } Everything works great. But I have … Read more