How to import .refCount () in rxjs / angular

I have angular2-seed

an angular 2 app. I have the following angular / rx code:

this.http.get(...).map((res) => res.json()).publishReplay().refCount();

      

I use

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/publishreplay';

      

to import all operators separately. But there seems to be no file to import the statement refCount

... or am I missing something. I'm sure there must be such a file, maybe it's stored elsewhere.

A brute force solution, the only one I managed to get is very brutal:

import 'rxjs';

      

I am using rxjs

v5

+3


source to share


1 answer


refCount

is a method ConnectableObservable

. It is not a statement that can be added to an arbitrary observable, so there is no file rxjs/add/operator/refCount

.

refCount

can only be used in conjunction with return operators ConnectableObservable

.



The operator publishReplay

returns ConnectableObservable

, so no additional imports are required for use refCount

with publishReplay

.

Also, you should be aware that imports rxjs/add/operator/publishreplay

will not work with case-sensitive file systems, since the filename publishReplay

.

+6


source







All Articles