angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 232 forks source link

Use pipeable operators instead of imperative imports #174

Closed mgol closed 6 years ago

mgol commented 6 years ago

There are places (like this one in http-client-backend.service.ts) where this module uses the old-style RxJS imperative imports. They should be switched to the new pipeable operators that don't rely on side-effects.

I've discovered this in my app where removing in-memory-web-api made some modules suddenly fail due to missing map & filter methods on observables.

mgol commented 6 years ago

Correction - it's actually the imports from rxjs/add that are adding these methods to the prototype:

https://github.com/angular/in-memory-web-api/blob/f7e216d626207f5a553aa710463b5d06b39b8c43/src/app/http-client-hero.service.ts#L7-L9

wardbell commented 6 years ago

You are looking at the sample app, not the library. The library does NOT import 'rxjs/add/operator';; let me know if you find where it does.

This library is supposed to work with the old RxJS method chaining as well as the newer pipeable operators. The sample app still reflects the old approach. But this shouldn't affect your user-land code at all. When you include this library in your application, you should not find that those methods have been added to prototypes in YOUR code.

I'll leave this open a few days so you can contradict me. I'd need to see a repro.

Thanks. W

mgol commented 6 years ago

I'm sorry, you're right; it was another package that was importing from 'rxjs/add/operator' in my project.