Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
655 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | import { Observable } from '../Observable';
|
---|
| 2 | import { SchedulerLike } from '../types';
|
---|
| 3 | import { Subscription } from '../Subscription';
|
---|
| 4 |
|
---|
| 5 | export function schedulePromise<T>(input: PromiseLike<T>, scheduler: SchedulerLike) {
|
---|
| 6 | return new Observable<T>(subscriber => {
|
---|
| 7 | const sub = new Subscription();
|
---|
| 8 | sub.add(scheduler.schedule(() => input.then(
|
---|
| 9 | value => {
|
---|
| 10 | sub.add(scheduler.schedule(() => {
|
---|
| 11 | subscriber.next(value);
|
---|
| 12 | sub.add(scheduler.schedule(() => subscriber.complete()));
|
---|
| 13 | }));
|
---|
| 14 | },
|
---|
| 15 | err => {
|
---|
| 16 | sub.add(scheduler.schedule(() => subscriber.error(err)));
|
---|
| 17 | }
|
---|
| 18 | )));
|
---|
| 19 | return sub;
|
---|
| 20 | });
|
---|
| 21 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.