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.

Recommendation clarification for Observables

See original GitHub issue

Description

I would like to ask the core developers to clarify/expand the following sentence in the documentation for Observables: “They are used frequently in Angular and are the recommended technique for event handling, asynchronous programming, and handling multiple values.”.

Problem: asynchronous programming here is a little bit wide. In some cases it might be interpreted as “do not use promises at all” [1][2]. As this is an official documentation and people who start to dive into angular tend to read documentation as a single truth, I would like to reduce a number interpretations.

important: this issue is not about observables vs promises.


[1]: as for some people…

  1. learning two concepts (promises/observables) is irrational as they can concentrate on a single concept (but as angular recommends to use observables, the choice is obvious);
  2. async and await aren’t in a comfort zone;
  3. who has never worked with event driven APIs (example: node.js) (to get a feel for the difference in these concepts) is not clear when to use promises as the observable is more powerful (read: rxjs) and with canceling.

[2]: which is not the case according the angular codebase itself where we can find promises.


Proposal

  1. Add a new clarification describing why/when promises should (not) be used and (one of) a. To remove asynchronous programming from the mentioned paragraph. b. Keep asynchronous programming
  2. Or remove the recommendation part completely (and are the recommended technique for event handling, asynchronous programming, and handling multiple values.).
  3. Replace “the recommended technique” with “a technique”.

URL:

https://angular.io/guide/observables

Similars

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kkamkoucommented, Oct 8, 2020

Angular chooses to use them over promises…

If you dig in the core module you’ll find the usage of promises. My assumption is that angular uses both of them in context.

Nevertheless, removing “the recommended technique” would decrease a number of interpretations: “Observables provide support for passing messages between parts of your application. They are used frequently in Angular and are a technique for event handling, asynchronous programming, and handling multiple values.”

1reaction
Airbladercommented, Oct 8, 2020

I think that Angular’s documentation on observables should be limited to describing what they are (since they’re used in the framework) and, possibly, why Angular chooses to use them over promises. But it shouldn’t say »and this is how we recommend you deal with things in your application«.

Given that the only thing I slightly disagree with in the sentence you’re quoting is the phrase “the recommended technique”, it could be replaced with “a technique”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clarifying Observables - Emarsys Craftlab
We start the operation with a function call and the returned Observable/Promise emits the result/error later in time. This is where the ...
Read more >
An introduction to observables in Reactive Programming
An Observable is simply a collection of data that waits to be invoked (subscribed) before it can emit any data. If you've worked...
Read more >
Angular Basics: Introduction to Observables (RxJS)—Part 1
In the first article of two parts, we'll cover the basics of observables, observers and RxJS.
Read more >
Understand how RxJS Observables and Subjects work and ...
In this article, we went through a lot of interesting concepts. Starting from what is RxJS library, through push and pull models, to...
Read more >
angular - Should a reference to an observable be kept or will ...
Until you do not unsubscribe to the observable, the data will not be garbage collected. However, if it is an HTTP observable we...
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