PromiseObservable.d.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { IScheduler } from '../Scheduler';
  2. import { Observable } from '../Observable';
  3. import { Subscriber } from '../Subscriber';
  4. import { TeardownLogic } from '../Subscription';
  5. /**
  6. * We need this JSDoc comment for affecting ESDoc.
  7. * @extends {Ignored}
  8. * @hide true
  9. */
  10. export declare class PromiseObservable<T> extends Observable<T> {
  11. private promise;
  12. private scheduler;
  13. value: T;
  14. /**
  15. * Converts a Promise to an Observable.
  16. *
  17. * <span class="informal">Returns an Observable that just emits the Promise's
  18. * resolved value, then completes.</span>
  19. *
  20. * Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an
  21. * Observable. If the Promise resolves with a value, the output Observable
  22. * emits that resolved value as a `next`, and then completes. If the Promise
  23. * is rejected, then the output Observable emits the corresponding Error.
  24. *
  25. * @example <caption>Convert the Promise returned by Fetch to an Observable</caption>
  26. * var result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
  27. * result.subscribe(x => console.log(x), e => console.error(e));
  28. *
  29. * @see {@link bindCallback}
  30. * @see {@link from}
  31. *
  32. * @param {PromiseLike<T>} promise The promise to be converted.
  33. * @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling
  34. * the delivery of the resolved value (or the rejection).
  35. * @return {Observable<T>} An Observable which wraps the Promise.
  36. * @static true
  37. * @name fromPromise
  38. * @owner Observable
  39. */
  40. static create<T>(promise: PromiseLike<T>, scheduler?: IScheduler): Observable<T>;
  41. constructor(promise: PromiseLike<T>, scheduler?: IScheduler);
  42. /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<T>): TeardownLogic;
  43. }