old-way rxjs operators and factory methods vs lettable ones
See original GitHub issueI 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.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
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
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.