All files utils.ts

91.67% Statements 22/24
25% Branches 1/4
90% Functions 9/10
90% Lines 18/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 394x 4x   4x   4x 7x 7x   7x 7x 7x                   7x       4x 22x   51x 17x 17x     4x   4x 22x    
import {observeOn} from 'rxjs/operator/observeOn';
import {queue} from 'rxjs/scheduler/queue';
import {Subscription} from 'rxjs/Subscription';
import {Observable} from 'rxjs/Observable';
 
export function fromPromise<T>(promiseFn: () => Promise<T>): Observable<T> {
  return new Observable<T>(subscriber => {
    promiseFn().then(
      result => {
        Eif (!subscriber.closed) {
          subscriber.next(result);
          subscriber.complete();
        }
      },
      error => {
        if (!subscriber.closed) {
          subscriber.error(error);
        }
      },
    );
 
    return () => subscriber.unsubscribe();
  });
}
 
export class ZoneScheduler {
  constructor(private zone: Zone) {}
 
  public schedule(...args: any[]): Subscription {
    return <Subscription>this.zone.run(() => {
      return queue.schedule.apply(queue, args);
    });
  }
}
 
export function wrapWithZone<T>(obs: Observable<T>): Observable<T> {
  return observeOn.call(obs, new ZoneScheduler(Zone.current));
}