本文整理汇总了TypeScript中rxjs.Observable.combineLatest方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.combineLatest方法的具体用法?TypeScript Observable.combineLatest怎么用?TypeScript Observable.combineLatest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs.Observable
的用法示例。
在下文中一共展示了Observable.combineLatest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: asObservable
asObservable(): Observable<MessageSetting> {
return Observable.combineLatest(
this._showJoin.asObservable(),
this._showPart.asObservable(),
this._showMode.asObservable(),
this._showMotd.asObservable(),
this._showNickChange.asObservable(),
this._showQuit.asObservable(),
(showJoin, showPart, showMode, showMotd, showNickChange, showQuit) => {
return {
showJoin,
showPart,
showMode,
showMotd,
showNickChange,
showQuit,
};
}
);
}
示例2:
.mergeMap(l => {
const vendors: Observable<{ item: any, vendors: Vendor[] }>[] = [];
this.forEachItem(list, item => {
const related = this.getRelated(data, item.id);
if (related !== undefined && related.vendors !== undefined) {
vendors.push(this.getVendors(related).map(ts => {
return {item: item, vendors: ts};
}));
}
});
if (vendors.length > 0) {
return Observable.combineLatest(...vendors, (...pvendors) => {
pvendors.forEach(v => {
v.item.vendors = v.vendors;
});
return l;
});
} else {
return Observable.of(l);
}
})
示例3: it
it('should make multiple user event Observables', function (done) {
const userEvents = mockDOMSource({
'.foo': {
'click': Observable.of(135),
},
'.bar': {
'scroll': Observable.of(2),
},
});
Observable.combineLatest(
userEvents.select('.foo').events('click'),
userEvents.select('.bar').events('scroll'),
(a: number, b: number) => a * b,
).subscribe({
next: ev => {
assert.strictEqual(ev, 270);
done();
},
error: err => done(err),
complete: () => {},
});
});
示例4: ngOnInit
ngOnInit() {
let filterTodos = (val: boolean) => (item: Todo) => item.completed === val;
this.hideCompleted$ = this.ngRedux.select(state => {
return !state.filter.showCompleted;
});
this.todos$ = this.ngRedux
.select(n => n.todos);
this.completedTodos$ = this.todos$
.map(todos => todos.filter(filterTodos(true)));
this.incompleteTodos$ = this.todos$
.map(todos => todos.filter(filterTodos(false)));
this.total$ = this.todos$.pluck('length');
this.completed$ = this.completedTodos$.pluck('length');
this.filteredTodos$ = this.todos$
.combineLatest(this.hideCompleted$, (todos, filter) => {
return todos.filter(n => filterTodos(false)(n) || filter === false);
});
this.ngRedux.mapDispatchToTarget({
completeTodo,
editTodo,
deleteTodo,
filterCompleted,
completeAll,
clearCompleted,
addTodo
})(this);
}
示例5: constructor
constructor(router: Router, zone: NgZone) {
if (typeof prebootstrap === 'undefined') {
return;
}
const finished = Observable.combineLatest(router.events, zone.onMicrotaskEmpty);
const subscription = finished.subscribe(([event, stable]) => {
if (stable === false) {
return;
}
switch (true) {
case event instanceof NavigationError:
case event instanceof NavigationEnd:
setImmediate(() => prebootClient().complete());
subscription.unsubscribe();
break;
default:
break;
}
});
}
示例6:
export const constructedPlaylistItem = (store: any) => Observable
.combineLatest(store.let(playlistSelector),
store.let(artistSelector),
store.let(audioSelector),
store.let(playlistArraySelector))
.map((res: any) => {
console.log("[playlist.selector] --constructedPlaylistItem- playlistArraySelector --res[0] ", res[0]);
// console.log("[playlist.selector] --constructedPlaylistItem- artistSelector --res[1] ", res[1]);
// console.log("[playlist.selector] --constructedPlaylistItem- audioSelector --res[2] ", res[2]);
var playlist = Object.assign({}, res[0]);
console.log("[playlist.selector] --constructedPlaylistItem- playlistArraySelector --res[0].length "+ res[0].length);
console.log("[playlist.selector] --constructedPlaylistItem- playlistArraySelector --playlist.audioList.length = "+ playlist.audioList.length);
if(playlist.audioList.length>0 ){
var artistAudioItem = Object.keys(res[1]) .filter( x => {
return res[1][x].id === res[2].artistId})
.map(x => {return res[1][x]})[0];
var newResult = Object.keys(playlist.audioList).map(key => ({key:key, playlistItem:playlist.audioList[key]})).map( value =>{
// obj = res[0][value.key];
console.log("playlist.selector] --constructedPlaylistItem --value ",value);
console.log("playlist.selector] --constructedPlaylistItem --value.playlistItem.artistId", value.playlistItem.artistId);
// console.log("playlist.selector] --constructedPlaylistItem --artistAudioItem.id", artistAudioItem.id);
if(value.playlistItem.artistId === artistAudioItem.id){
playlist.audioList[value.key] = Object.assign({}, value.playlistItem, {artist:artistAudioItem} );
//console.log("playlist.selector] --constructedPlaylistItem -- playList[value.key] =", playList[value.key]);
}
});
console.log("playlist.selector] --constructedPlaylistItem --valueer --playlist.audioList ", playlist.audioList);
return playlist.audioList;
}else{
console.log("[playlist.selector] -- constructedPlaylistItem -- DEFAULT");
return res[3];
}
});