当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Observer.complete方法代码示例

本文整理汇总了TypeScript中rxjs/Observer.Observer.complete方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observer.complete方法的具体用法?TypeScript Observer.complete怎么用?TypeScript Observer.complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs/Observer.Observer的用法示例。


在下文中一共展示了Observer.complete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ExecutionCompletedAction

                process.on("exit", (code: number, sig) => {
                    processStillRunning = false;

                    /** Successful completion if exit code is 0 */
                    const isCompleted = code === 0;

                    /**
                     * Killing a process manually will throw either exitCode 143, or
                     * a SIGINT/SIGTERM/SIGKILL in different circumstances, so we check for both
                     * */
                    const isCancelled = code === 143 || sig;


                    if (isCompleted) {
                        this.store.dispatch(new ExecutionCompletedAction(appID));
                        obs.complete();
                        return;

                    } else if (isCancelled) {
                        /**
                         * Cancellation is initially triggered from unsubscribing from killing the process
                         * when unsubscribing from the observable.
                         * ExecutionStopAction is therefore dispatched from the original place.
                         * @see executionUnsubscribe
                         */
                        obs.complete();
                        return;
                    } else {
                        this.store.dispatch(new ExecutionErrorAction(appID, new ExecutionError(code)));
                        obs.error(new Error(`Execution failed with exit code ${code}.`));
                    }

                });
开发者ID:hmenager,项目名称:composer,代码行数:33,代码来源:executor.service.ts

示例2: isPresent

      let onLoad = () => {
        // responseText is the old-school way of retrieving response (supported by IE8 & 9)
        // response/responseType properties were introduced in XHR Level2 spec (supported by
        // IE10)
        let body = isPresent(_xhr.response) ? _xhr.response : _xhr.responseText;

        let headers = Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());

        let url = getResponseURL(_xhr);

        // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
        let status: number = _xhr.status === 1223 ? 204 : _xhr.status;

        // fix status code when it is 0 (0 status is undocumented).
        // Occurs when accessing file resources or on Android 4.1 stock browser
        // while retrieving files from application cache.
        if (status === 0) {
          status = body ? 200 : 0;
        }
        var responseOptions = new ResponseOptions({body, status, headers, url});
        if (isPresent(baseResponseOptions)) {
          responseOptions = baseResponseOptions.merge(responseOptions);
        }
        let response = new Response(responseOptions);
        if (isSuccess(status)) {
          responseObserver.next(response);
          // TODO(gdi2290): defer complete if array buffer until done
          responseObserver.complete();
          return;
        }
        responseObserver.error(response);
      };
开发者ID:844496869,项目名称:angular,代码行数:32,代码来源:xhr_backend.ts

示例3:

 return Observable.create((observer:Observer<any>) => {
   debugger;
   observer.next([
     {id: 1, contentMarkdown: 'abc', contentRendered: 'abc', title: 'demo'}
   ]);
   observer.complete();
 });
开发者ID:liuyijie,项目名称:angular2-webpack-demo-routing-and-http,代码行数:7,代码来源:blog-roll.spec.ts

示例4: catchResponse

 catchResponse(res:Response,observer:Observer<Response>):void {
     if(res.status === 403) {
         console.log('Unauthorized request:',res.text());
         this.accountEventsService.logout({error:res.text()});
     }
     observer.complete();
 }
开发者ID:fensminger,项目名称:SyncFiles,代码行数:7,代码来源:hmac-http-client.ts

示例5: return

  return new Observable<T>((observer: Observer<T>) => {
    observers.push(observer);

    values.forEach((value: T) => {
      observer.next(value);
    });

    if (completed) {
      observer.complete();
    }

    if (!subscription) {
      subscription = this.subscribe(
        sendNext,
        sendError,
        sendComplete
      );
    }

    return () => {
      const i = observers.indexOf(observer);
      if (i !== -1) {
        observers.splice(i, 1);
      }

      if (observers.length === 0 && subscription) {
        subscription.unsubscribe();
      }
    };
  });
开发者ID:StephenFluin,项目名称:ames,代码行数:30,代码来源:shareResults.ts

示例6:

 (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => {
   if (status === google.maps.GeocoderStatus.OK) {
     observer.next(results[0].formatted_address);
     observer.complete();
   } else {
     observer.error(status);
   }
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:8,代码来源:reverse-geocode.service.ts

示例7:

 const onComplete = () => {
   if (savedError !== null) {
     observer.error(savedError);
   } else {
     observer.next(savedResult);
     observer.complete();
   }
 };
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:8,代码来源:http.ts

示例8:

 (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => {
     if (status === google.maps.GeocoderStatus.OK) {
         observer.next(results);
         observer.complete();
     } else {
         console.log('Geocoding service: geocoder failed due to: ' + status);
         observer.error(status);
     }
 })
开发者ID:robisim74,项目名称:angular2maps,代码行数:9,代码来源:geocoding.service.ts

示例9: function

			xhr.onreadystatechange = function () {
				if (xhr.readyState == XMLHttpRequest.DONE) {
					if (xhr.status >= 200 && xhr.status < 300) {
						thatObserver.next(xhr.responseText);
						thatObserver.complete();
					} else {
						thatObserver.error(xhr.responseText);
					}
				}
			};
开发者ID:freekode,项目名称:bikelife,代码行数:10,代码来源:HttpService.ts

示例10: ExecutionStoppedAction

            const cleanup = () => {
                if (processStillRunning) {
                    this.store.dispatch(new ExecutionStoppedAction(appID));
                }

                if (execution) {
                    execution.kill();
                }
                obs.complete();
            };
开发者ID:hmenager,项目名称:composer,代码行数:10,代码来源:executor.service.ts


注:本文中的rxjs/Observer.Observer.complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。