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


TypeScript Observable.combineLatest方法代码示例

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


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

示例1: model

function model(props$: Observable<RadioButtonProps>, actions: any) {
  const clickedValue$ = Observable.combineLatest(
    actions.itemMouseClick$, props$, (click, props) => props.value)
    .do(x => console.log('clickedValue ' + x));

  const radioGroupValue$ = Observable.just('RadioHard');
  const checked$ = Observable.combineLatest(props$, clickedValue$, radioGroupValue$,
      (props, clickedValue, radioGroupValue) => {
    //TODO: does this stop having a disabled and checked, not just initial state?
    return !props.disabled && (clickedValue === radioGroupValue);
  })
  .do(x => console.log('checked ' + x));

  return combineLatestObj({clickedValue$, props$, checked$ });
}
开发者ID:eldarlabs,项目名称:cycle-ui,代码行数:15,代码来源:RadioButton.ts

示例2: formatDate

  setDate: (startDate, endDate) => {
    const daysInRange = [];
    moment.range([startDate, endDate]).by('days', m => daysInRange.push(m));

    const dates = Array.from(daysInRange.keys())
      .map(i => formatDate(moment(startDate).add(i, 'days')))
      .filter(date => moment(date).isSameOrBefore(moment(endDate)));


    articles.update(dates);
    articlesWithVideos.update(dates);
    videosProduced.update(dates);
    allMediaEvents.update(dates);

    const mediaEventsDays = dates.map(allMediaEventsStat$);
    const mediaEventsSub$ = Rx.Observable.combineLatest(...mediaEventsDays).subscribe(mediaEvents => {
      // We shouldn't be sending these all over, but it gives us the flexibility in the template for now
      const articles = addMediaEvents(mediaEvents.map(mediaEvent => mediaEvent.articles));
      const fronts = addMediaEvents(mediaEvents.map(mediaEvent => mediaEvent.fronts));
      const videoPages = addMediaEvents(mediaEvents.map(mediaEvent => mediaEvent.videoPages));
      const total = addMediaEvents([articles, fronts, videoPages]);

      mediaEvents$.onNext(mediaEvents);

      mediaEventTotals$.onNext({total, articles, fronts, videoPages});
      mediaEventsSub$.dispose();
    });

  }
开发者ID:guardian,项目名称:video-dashboard,代码行数:29,代码来源:app.ts

示例3: update

 function update(dates) {
   const days = dates.map(stat$);
   const sub$ = Rx.Observable.combineLatest(...days).subscribe(data => {
     const total = data.reduce((prev, next) => prev + next.total, 0);
     data$.onNext(data);
     total$.onNext(total);
     sub$.dispose();
   });
 }
开发者ID:guardian,项目名称:video-dashboard,代码行数:9,代码来源:app.ts

示例4: view

function view(state$: Observable<any>, actions$: Observable<any>) {
    return Observable
        .combineLatest(
            github$,
            state$,
            actions$.startWith(undefined),
            (github, state, action) => ({ state: assign(state, { github }), action }))
        .map((props: any) =>
            React.createElement(App, props));
}
开发者ID:duncanmak,项目名称:experiments,代码行数:10,代码来源:view.ts

示例5: MediaEvent

export const allMediaEvents$ = date => {
  const frontsTotal$ = getFrontsMediaEvents$(date).catch(() => new MediaEvent());
  const pageTotal$ = getPageMediaEvents$(date).catch(() => new MediaEvent());

  return Rx.Observable.combineLatest(frontsTotal$, pageTotal$, (frontsTotal, pageTotal) =>
    ({
      date,
      fronts: frontsTotal,
      videoPages: pageTotal.videoPages,
      articles: pageTotal.articlePages
    }));
};
开发者ID:guardian,项目名称:video-dashboard,代码行数:12,代码来源:stats.ts

示例6: classNames

  const vtree$ = props$.map( (props) => {

    const $radioGroupSelectedValue = Observable.combineLatest(childrenValues, (...values) => {
      return { itemMouseClick$ };
    }).startWith(props.value)
      .do(x => console.log('radioGroupSelectedValue ' + x));

    const className = classNames('radioGroup', props.className);

    return (
      div( { props: { className }, attrs: { 'data-cycle-ui': 'radio-group' } },
        childrenDOMs
      )
    );
  });
开发者ID:eldarlabs,项目名称:cycle-ui,代码行数:15,代码来源:RadioGroup.ts

示例7: getGameHighScores

  let main = ({ bot }: Sources) => ({
    bot: $.from([
      $.just(sendGame(
        { chat_id: GROUP_ID,
          game_short_name: 'test' },
        {})),

      bot.events('message')
        .pluck<TcombUser>('message', 'from')
        .do(() => bot.dispose())
        .combineLatest<TcombMessage, MessageUser>(bot.responses.take(1), (user, message) => ({ message, user }))
        .map(({ message, user }) =>
          getGameHighScores(
            { user_id: user.id, message_id: message.message_id },
            { message })),

      $.combineLatest<any, any, MessageUserScore>(
        bot.responses
          .take(1)
          .combineLatest(bot.events('message').do(() => bot.dispose()).pluck('message', 'from')),
        bot.responses
          .skip(1)
          .filter(Array.isArray)
          .flatMap($.from),
        ([message, user], score) => ({ message, user, score }))
        .filter(({user, score}) => user.id === score.user.id)
        .map(({ score: { score }, user, message }) =>
          setGameScore(
            { score: score + 1, user_id: user.id, message_id: message.message_id },
            { message })),

      bot.responses
        .skip(1)
        .filter(prop('game'))
        .pluck('game')
        .do((game: TcombGame) => {
          bot.dispose()
          t.ok(Game.is(Game(game)), 'game satisfies typecheck')
          t.end()
        })
    ])
  })
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:42,代码来源:rx.ts


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