本文整理匯總了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()
}
}
示例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("/"))
});
示例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
]));
});