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


TypeScript Observer.next方法代码示例

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


在下文中一共展示了Observer.next方法的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: setTimeout

 setTimeout(() => {
   observer.next([
     {label: 'First', content: 'Content 1'},
     {label: 'Second', content: 'Content 2'},
     {label: 'Third', content: 'Content 3'},
   ]);
 }, 1000);
开发者ID:OkBayat,项目名称:material2,代码行数:7,代码来源:tab-group-async-example.ts

示例3:

 const connectionHandler = (socket: Socket) => {
   let os: Observable<IRxSocket>;
   os = observableFromStream<Buffer>(socket).map(obsBuf => {
     return {socket, buffer: obsBuf};
   });
   observer.next(os);
 };
开发者ID:dancasey,项目名称:node-rx-server,代码行数:7,代码来源:rxserver.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:

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

示例6:

 return new Observable<IFeed[]>((observer: Observer<IFeed[]>) => {
   // emiting values
   observer.next([{
     'id': 'fid1',
     'title': 'Post 1',
     'description': 'Post Description 1'
   }]);
   // to complete stream use observer.complete();
 });
开发者ID:ramana-chavakula,项目名称:angular2-webpack,代码行数:9,代码来源:feedsList.component.spec.ts

示例7: Observable

  return new Observable((observer : Observer<void>) => {
    log.info("Setting URL to Element", url, mediaElement);

    mediaElement.src = url;

    observer.next(undefined);
    return () => {
      clearElementSrc(mediaElement);
    };
  });
开发者ID:canalplus,项目名称:rx-player,代码行数:10,代码来源:set_element_src.ts

示例8: 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

示例9:

 .then(tmdbconfig => {
     if (tmdbconfig == null) {
         let uri: string = AppSettings.TMDB_BASEURI + "/configuration?api_key=" + AppSettings.TMDB_APIKEY;
         this.http.get(uri)
                  .map(response => response.json())
                  .subscribe((data : TmdbConfigResponse) => {
                     this.storage.set("tmdb_config", JSON.stringify(data));
                     this.tmdbConfigObserver.next(data);
                  });
     } else {
         this.tmdbConfigObserver.next(JSON.parse(tmdbconfig));
     }
 }, err => {
开发者ID:KajB,项目名称:WatchIT,代码行数:13,代码来源:tmdb-config.service.ts

示例10: emitSample

    /**
     * Emit timings sample.
     * Meant to be used as a callback on various async events.
     * @param {Event} [evt] - The Event which triggered the callback, if one.
     */
    function emitSample(evt? : Event) {
      const state : IMediaInfosState = evt && isMediaInfoState(evt.type) ?
        evt.type : "timeupdate";
      const mediaTimings = getMediaInfos(mediaElement, state);
      const stalledState = getStalledStatus(lastTimings, mediaTimings, withMediaSource);

      // /!\ Mutate mediaTimings
      lastTimings = objectAssign(mediaTimings,
        { stalled: stalledState }
      );
      log.debug("API: new clock tick", lastTimings);
      obs.next(lastTimings);
    }
开发者ID:canalplus,项目名称:rx-player,代码行数:18,代码来源:clock.ts


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