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

Use Promise to Replace Observable Only Emitting Once #233

Closed
seanwu1105 opened this issue Nov 18, 2020 · 3 comments
Closed

Use Promise to Replace Observable Only Emitting Once #233

seanwu1105 opened this issue Nov 18, 2020 · 3 comments
Assignees
Labels
code Improvements to code quality or project architecture
Milestone

Comments

@seanwu1105
Copy link
Contributor

seanwu1105 commented Nov 18, 2020

Since currently there is no Single class (like rxjava) in rxjs, it could be difficult for developers to figure out if the Observable only emits once. There are several discussion about this problem. E.g. ReactiveX/rxjs#5273.

We should use Promise instead of Observable to clearly indicate the behavior will only return ONE SINGLE value asynchronously. This would help developers to avoid lots of potential bugs when deciding which observable operator to use, such as forkJoin vs zip and toArray vs scan.

As a Promise can be easily transform into an Observable with defer function but it is an anti-pattern to transform an Observable into a Promise via toPromise function, we should:

  • Prefer Promise than Observable for return values.
  • Prefer Observable than Promise for parameters.
@seanwu1105 seanwu1105 added the code Improvements to code quality or project architecture label Nov 18, 2020
@seanwu1105 seanwu1105 added this to the backlog milestone Nov 18, 2020
@seanwu1105
Copy link
Contributor Author

The new Database service replacing utils/storage class (#227) has adopted this practice.

@seanwu1105 seanwu1105 modified the milestones: backlog, beta7, beta7.1 Nov 25, 2020
@seanwu1105
Copy link
Contributor Author

The new BlockingActionService (#268) has adopted this practice.

@seanwu1105
Copy link
Contributor Author

The new PreferenceManager and Preferences (#269) has adopted this practice.

@seanwu1105 seanwu1105 self-assigned this Nov 27, 2020
seanwu1105 added a commit that referenced this issue Dec 1, 2020
Use Promise to Replace Observable Only Emitting Once. See #233.

- Remove impl suffix from table preferences classes.
- Remove unused utils.
- Suppress tslint:await-promise rule for crypto.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Improvements to code quality or project architecture
Projects
None yet
Development

No branches or pull requests

1 participant