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.

Update example code due to deprecations in RxJS

See original GitHub issue

Which @angular/* package(s) are relevant/releated to the feature request?

No response

Description

In documentation in example codes there are many usages of RxJS. Several functions are going to be deprecated or already deprecated and will be removed in next major release.

For example in developer guide for HTTP Client, interceptors part (Logging request and response pairs) the following code-snippet with tap-function uses deprecated form of the tap:

...
tap(
  // Succeeds when there is a response; ignore other events
  event => ok = event instanceof HttpResponse ? 'succeeded' : '',
  // Operation failed; error is an HttpErrorResponse
  error => ok = 'failed'
),
...

The deprecation note for the function used: “Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments

See more for details: https://rxjs.dev/api/operators/tap

Proposed solution

The replacement of the provided snippet by the following:

...
tap({
  next: event => ok = event instanceof HttpResponse ? 'succeeded' : '',
  error: error => ok = 'failed'
}),
...

Alternatives considered

No alternatives.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JoostKcommented, Jan 17, 2022

Yep

1reaction
yousafnawazcommented, Jan 17, 2022

You could also use the docs prefix. I’d suggest to change the tap into the tap operator, as without operator that sentence looks unfinished.

Please also include a Closes #44708 comment in a new paragraph such that this issue is automatically closed when the commit is merged.

“docs(examples): update deprecated form of the tap operator” looks fine now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecations - RxJS
Deprecations link ; multicast, Will be removed in v8. Use the connectable observable, the connect operator or the share operator instead. See the...
Read more >
Subscribe is deprecated: Use an observer instead of an error ...
subscribe isn't deprecated, only the variant you're using is deprecated. In the future, subscribe will only take one argument: either the ...
Read more >
Deprecated APIs and features - Angular
To help you future-proof your projects, the following table lists all deprecated APIs and features, organized by the release in which they are...
Read more >
RxJS heads up: toPromise is being deprecated - InDepth.Dev
In RxJS 7 toPromise will become deprecated and with RxJS 8 it will be gone! So avoid using toPromise in your future development...
Read more >
RxJS 6: What's new and what has changed? - Auth0
In the rare instance that your codebase defines its own TypeScript prototype operators and modifies the Observable namespace, your operator code ...
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