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


TypeScript Observer.complete方法代码示例

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


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

示例1: function

    var observe = Observable.create(function(
        obs: Observer<inquirer.Question<{ phone: string }>>
    ) {
        obs.next({
            type: "input",
            name: "first_name",
            message: "What's your first name"
        });

        obs.next({
            type: "input",
            name: "last_name",
            message: "What's your last name",
            default: function() {
                return "Doe";
            }
        });

        obs.next({
            type: "input",
            name: "phone",
            message: "What's your phone number",
            validate: function(value) {
                var pass = value.match(
                    /^([01]{1})?[-.\s]?\(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i
                );
                if (pass) {
                    return true;
                }

                return "Please enter a valid phone number";
            }
        });
        obs.complete();
    });
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:35,代码来源:inquirer-tests.ts

示例2: Observable

    return new Observable((obs : Observer<U>) => {
      let hasErroredOrCompleted = false;
      if (isPending) {
        hasErroredOrCompleted = true;
        obs.complete();
        return undefined;
      }

      isPending = true;
      func(...args)
        .subscribe(
          (i) => { obs.next(i); },
          (e) => {
            hasErroredOrCompleted = true;
            isPending = false;
            obs.error(e);
          },
          () => {
            hasErroredOrCompleted = true;
            isPending = false;
            obs.complete();
          }
        );

      return () => {
        // handle unsubscription
        if (!hasErroredOrCompleted) {
          isPending = false;
        }
      };
    });
开发者ID:canalplus,项目名称:rx-player,代码行数:31,代码来源:rx-throttle.ts

示例3:

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

示例4: return

 return ({ err, response, isDisposed }: WritePacket) => {
   if (err) {
     return observer.error(err);
   } else if (isDisposed) {
     return observer.complete();
   }
   observer.next(response);
 };
开发者ID:a1r0,项目名称:nest,代码行数:8,代码来源:client-proxy.ts

示例5: handleInvalidWorkstation

    handleInvalidWorkstation(path: string): void {

        if (path.startsWith(WS_MANAGE_PATH)) {
            // user is navigating to the WS admin page.
            this.observer.complete();
        } else {
            this.router.navigate([WS_MANAGE_PATH]);
            this.observer.error(`Auth session linked to no
                workstation or a workstation unknown to this browser`);
        }
    }
开发者ID:StephenGWills,项目名称:Evergreen,代码行数:11,代码来源:resolver.service.ts

示例6: catch

 .then((data) => {
     try {
         const json = JSON.parse(data);
         observer.next(successResponse(url, json, 200));
         observer.complete();
     } catch (error) {
         // Even though the response status was 2xx, this is still an error.
         // The parse error contains the text of the body that failed to parse.
         const errorResult = { error, text: data };
         observer.error(errorResponse(url, errorResult, 200));
     }
 }, (err: Object) => {
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:12,代码来源:http-utils.ts

示例7:

			.then(action => {
				if (/\s*done\s*/.test(action)) {
					observer.complete();
				} else {
					const result = this._interpreter.interpret(action);
					if (Maybe.isDefined(result)) {
						return result.progress
							.then(actionResult => observer.next(actionResult))
							.then(() => this.captureAction(observer, false));
					} else {
						this._dialog.report('Cannot understand the action. Try again');
						return this.captureAction(observer, false);
					}
				}
			});
开发者ID:Kineolyan,项目名称:Jarvis,代码行数:15,代码来源:LearnRule.ts

示例8:

        return Observable.create((observer: Observer<Array<IPeopleEntity>>) => {

            let result: Array<IPeopleEntity> = [];

            for (let i = 0; i < 10; i++) {
                result.push({
                    Id: i.toString(),
                    Email: "marvio.bezerra@gmail.com",
                    Name: "Marvio Bezerra"
                });
            }

            observer.next(result);
            observer.complete();
        });
开发者ID:marviobezerra,项目名称:CrazyLabNode,代码行数:15,代码来源:People.Service.ts

示例9: debug

        return Observable.create((o: Observer<any>) => {
          if (!queryString) { return o.complete() }

          debug(`Executing query: ${queryString.substring(0, 300)}${queryString.length <= 300 ? '' : '...'}`)

          const query = client.query(queryString, (err) => {
            if (err) o.error(err)
            o.complete()
          })

          query.on('row', (row) => o.next(row))
          // query.on('error', (err) => o.error(err))
          // query.on('end', () => o.complete())

          return noop
        })
开发者ID:Alex0007,项目名称:mysql-query-observable,代码行数:16,代码来源:index.ts

示例10:

 return new Observable<AbstractProcess>((observer: Observer<AbstractProcess>) => {
     if (id) {
         this.service.getDescription(id).then((desc) => {
             this.description = desc;
             observer.next(this.description);
             observer.complete();
         }).catch((error) => {
             observer.error(error);
             observer.complete();
         });
     } else {
         if (!this.description) this.description = null;
         observer.next(this.description);
         observer.complete();
     }
 });
开发者ID:janschulte,项目名称:smle,代码行数:16,代码来源:EditorService.ts


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