Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

old-way rxjs operators and factory methods vs lettable ones #3222

Closed
maksfastovets opened this issue Jan 10, 2018 · 5 comments
Closed

old-way rxjs operators and factory methods vs lettable ones #3222

maksfastovets opened this issue Jan 10, 2018 · 5 comments

Comments

@maksfastovets
Copy link

maksfastovets commented Jan 10, 2018

I posted this question here but didn't get an answer. I think this question relates to the library documentation improvements so I put it here too.

I bumped into the problem with lettable operators, in particular, with timer.

For instance, this:
import 'rxjs/add/operator/catch'
-- still works and even changes Observable object globally so there's no need to import that 'catch' again in a certain ts file once it is imported in project module file.

And this:
import 'rxjs/add/observable/timer'
-- doesn't work anymore, instead:
import { timer } 'rxjs/observable/timer'
-- should be used and it doesn't modify Observable object, it is used as an independent function, and it cannot be imported globally, it should be imported in each ts file individually if it is needed.

Why is
import 'rxjs/add/operator/catch'
still in use and has its counterpart of
import {catchError} from 'rxjs/operators/catchError'
and
import 'rxjs/add/observable/timer'
is no longer in use?

Is there any documentation on the topic? On the import syntax migration?

Thank you.

@dmitrysteblyuk
Copy link

dmitrysteblyuk commented Jan 10, 2018

I guess operators can be imported the old way (import 'rxjs/add/operator/catch') because otherwise they wouldn't be available in observable chain.

I think this approach (being forced to import factory methods in every file) less error-prone because before for example you could import static method in a lazy module and it still would be ok with ts compiler to use it anywhere across your app, but would cause an error at runtime

@maksfastovets
Copy link
Author

leaving possibility to import operators in an old way while having new-way lettable operators saves lots of nerves to developers who use rxjs.

Why backward compatible support of some factory methods (timer, interval...) was removed while some other are still supported (of...) -- that's a mystery and a huge headache.

@benlesh
Copy link
Member

benlesh commented Jan 14, 2018

They're all still there in 5.5.

Technically, I would advise against using any of the rxjs/add/* variants, unless you're really sure you know what you're doing. It can just cause a lot of pain in larger projects or in bigger teams.

@benlesh
Copy link
Member

benlesh commented Jan 24, 2018

I think this can be closed. It was a misunderstanding.

@benlesh benlesh closed this as completed Jan 24, 2018
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants