Example #1
0
 observable1 = constructorZone1.run(() => {
   return Rx.Observable.defer(() => {
     return new Rx.Observable(subscribe => {
       log.push('setup');
       expect(Zone.current.name).toEqual(constructorZone1.name);
       subscribe.next(1);
       subscribe.complete();
       return () => {
         expect(Zone.current.name).toEqual(constructorZone1.name);
         log.push('cleanup');
       };
     });
   });
 });
Example #2
0
 /**
  * Executes this command asynchronously.
  * Note that this method does not check whether the command is currently executable.
  */
 public execute(arg: TArgs = null): Observable<TResult> {
     try {
         return Observable.defer(() => {
             this._synchronizedExcecutionInfo.next(ExecutionInfo.createBegin<TResult>());
             return Observable.empty<TResult>();
         })
             .concat(this.task(arg))
             .do(
                 result => this._synchronizedExcecutionInfo.next(ExecutionInfo.createResult(result)),
                 null,
                 () => this._synchronizedExcecutionInfo.next(ExecutionInfo.createEnded<TResult>()))
             .catch(ex => {
                 this._synchronizedExcecutionInfo.next(ExecutionInfo.createFail<TResult>());
                 this._exceptions.next(ex);
                 return Observable.throw(ex);
             })
             .publishLast()
             .refCount();
     } catch (ex) {
         this._exceptions.next(ex);
         return Observable.throw(ex);
     }
 }