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


TypeScript Observable.zip方法代码示例

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


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

示例1: makeSources

export function makeSources (state: Observable<TcombUpdatesState>): DriverSources {
  let updates = state
    .pluck<TcombUpdate[]>('updates')
    .map((u: TcombUpdate[]) => $.from(u))
    .switch()
    .share()

  let startDate = state
    .pluck('startDate')
    .share()

  return {
    message: $.zip(updates, startDate)
      .filter(([update]) => Message.is(update.message))
      .filter(([update, startDate]) => (startDate - update.message.date * 1000) <= 30000)
      .map(([update]) => update)
      .share(),

    inlineQuery: updates
      .filter(propIs(InlineQuery, 'inline_query'))
      .share(),

    chosenInlineResult: updates
      .filter(propIs(ChosenInlineResult, 'chosen_inline_result'))
      .share(),

    callbackQuery: updates
      .filter(propIs(CallbackQuery, 'callback_query'))
      .share()
  }
}
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:31,代码来源:sources.ts

示例2:

router.get('/article/:permalink', (req, res, next) => {
  var urlParts = req.params['permalink'].split("-");
  var articleSource = urlParts[urlParts.length - 2];  //Get the "source" value
  var articleId = urlParts[urlParts.length - 1];  //Get the article id

  var postRx;
  if (articleSource == "gh") {
    postRx = gitHubLoader.loadPostById(articleId);
  } else {
    postRx = bloggerLoader.loadPostById(articleId);
  }

  Observable.zip(postRx, tumblrLoader.loadTumblrData(),
    (post, tumblrPosts) => {
      return {
        article: post,
        tumblr: tumblrPosts
      };
    }).subscribe(result => {
      res.render('article', { 
        articlePost: result.article,
        tumbrlPosts: result.tumblr
      });
    }, 
    err => res.redirect("/"))
});
开发者ID:creativedrewy,项目名称:creativedrewy.com,代码行数:26,代码来源:index.ts

示例3: drawChart

  const endDate = app.get('endDate');
  dateRange$.onNext({startDate, endDate});
});


// Write totals
articles.total$.subscribe(total => app.set('articlesTotal', total));
articlesWithVideos.total$.subscribe(total => app.set('articlesWithVideoTotal', total));
videosProduced.total$.subscribe(total => app.set('videosProducedTotal', total));
allMediaEvents.totals$.subscribe(totals => app.set('allMediaEventsTotals', totals));
mediaEventTotals$.subscribe(mediaEventTotals => app.set('mediaEventTotals', mediaEventTotals));


Rx.Observable.zip(
  articlesWithVideos.data$,
  articles.data$,
  videosProduced.data$,
  (articlesWithVideos, articles, videosProduced) =>
  ({articlesWithVideos, articles, videosProduced}))
  .subscribe(({articlesWithVideos, articles, videosProduced}) => {
  // TODO: zip
  drawChart('video-embeds', ['Day', 'Articles created, total', 'With video embedded', 'videos produced'], articles.map((article, i) => [
    article.date, articles[i].total, articlesWithVideos[i].total, videosProduced[i].total
  ]));
});

// Play graph
mediaEvents$.subscribe(mediaEvents => {
  drawChart('video-plays', ['Day', 'Starts in article', 'Starts in video pages', 'Starts on fronts'], mediaEvents.map(mediaEvent => [
    mediaEvent.date, mediaEvent.articles.plays, mediaEvent.videoPages.plays, mediaEvent.fronts.plays
  ]));
});
开发者ID:guardian,项目名称:video-dashboard,代码行数:32,代码来源:app.ts


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