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.

lettable toPromise?

See original GitHub issue

RxJS version: 5.5.0-beta

Code to reproduce:

import { of } from "rxjs/observable/of";
import {
	map,
	toPromise
} from "rxjs/operators";

export function demoFn(): Promise<void> {
	return of([null])
		.pipe(
			map(() => {}),
			toPromise()
		);
}

Expected behavior: No error Actual behavior:

Error:(11, 4) TS2345: Argument of type 'UnaryFunction<Observable<void>, Promise<void>>' is not assignable to parameter of type 'UnaryFunction<Observable<void>, Observable<{}>>'.
  Type 'Promise<void>' is not assignable to type 'Observable<{}>'.
    Property '_isScalar' is missing in type 'Promise<void>'.

Additional information:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

11reactions
jack-guycommented, Jan 25, 2018

@mebibou Don’t pipe. It’s on the Observable object by default.

Observable.of('foo').toPromise(); // this
Observable.of('foo').pipe(toPromise()); // not this
3reactions
mebiboucommented, Jan 5, 2018

So what is the proper way of using toPromise on Observable now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJS: How to Use Lettable Operators and Promises
Lettable operators are higher-order functions that return functions that receive and return observables. The toPromise higher-order function ...
Read more >
Nothing has changed.. The only promise-related change that… | by ...
The only promise-related change that was effected with the introduction of lettable/pipeable operators was the moving of toPromise from an operator to an ......
Read more >
toPromise - Learn RxJS
Convert observable to promise. ... ⚠ toPromise is not a pipable operator, as it does not return an observable.
Read more >
Error while importing RxJS operators in Angular - Stack Overflow
The catch and do operators were replaced with catchError and tap respectively. Nothing has to be imported for toPromise since it isn't pipeable ......
Read more >
Pipeable Operators - RxJS
The former toPromise() "operator" has been removed because an operator ... It used to be the origin of the name ("lettable"), but that...
Read more >

github_iconTop Related Medium Post

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