當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。