question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

old-way rxjs operators and factory methods vs lettable ones

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dmitrysteblyukcommented, 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

0reactions
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJS Operators
A Pipeable Operator is a function that takes an Observable as its input and returns another Observable. It is a pure operation: the...
Read more >
RxJS: Understanding Lettable Operators - ncjamieson
Lettable operators offer a new way of composing observable chains and they have advantages for both application developers and library authors.
Read more >
Deep dive into composing RxJS operators with `pipe`
Version 5 of RxJS introduced the concept of lettable (also known as pipeable) operators. Version 6 went one step further and deprecated the ......
Read more >
In Angular rxjs when should I use `pipe` vs `map`
The "new" way, using pipe , is called Lettable Operators Pipeable Operators. The "old" way, where you chain operators, is called using ...
Read more >
RxJS - Operators - Tutorialspoint
An operator is a pure function which takes in observable as input and the output is also an observable. To work with operators...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found