本文整理汇总了TypeScript中rxjs/Observable.Observable.connect方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.connect方法的具体用法?TypeScript Observable.connect怎么用?TypeScript Observable.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Observable.Observable
的用法示例。
在下文中一共展示了Observable.connect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getVersionInfo
private getVersionInfo(navigationInfo: Observable<NavigationResponse>) {
const versionInfo = navigationInfo
.map(response => response.__versionInfo)
.publishLast();
versionInfo.connect();
return versionInfo;
}
示例2: getSelectedNodes
/**
* Get an observable that will list the nodes that are currently selected
* We use `publishReplay(1)` because otherwise subscribers will have to wait until the next
* URL change before they receive an emission.
* See above for discussion of using `connect`.
*/
private getSelectedNodes(navigationViews: Observable<NavigationViews>) {
const selectedNodes = combineLatest(
navigationViews.map(this.computeUrlToNodesMap),
this.location.currentUrl,
(navMap, url) => navMap[url] || [])
.publishReplay(1);
selectedNodes.connect();
return selectedNodes;
}
示例3: getCategories
private getCategories(): Observable<Category[]> {
const categories = this.http.get<any>(resourcesPath)
.map(data => mkCategories(data))
.publishLast();
categories.connect();
return categories;
};
示例4: getNavigationViews
private getNavigationViews(navigationInfo: Observable<NavigationResponse>): Observable<NavigationViews> {
const navigationViews = navigationInfo.map(response => {
const views: NavigationViews = Object.assign({}, response);
Object.keys(views).forEach(key => {
if (key[0] === '_') { delete views[key]; }
});
return views;
}).publishReplay(1);
navigationViews.connect();
return navigationViews;
}
示例5: getCurrentNode
/**
* Get an observable of the current node (the one that matches the current URL)
* We use `publishReplay(1)` because otherwise subscribers will have to wait until the next
* URL change before they receive an emission.
* See above for discussion of using `connect`.
*/
private getCurrentNode(navigationViews: Observable<NavigationViews>): Observable<CurrentNode> {
const currentNode = combineLatest(
navigationViews.map(this.computeUrlToNavNodesMap),
this.location.currentPath,
(navMap, url) => {
const urlKey = url.startsWith('api/') ? 'api' : url;
return navMap[urlKey] || { view: '', url: urlKey, nodes: [] };
})
.publishReplay(1);
currentNode.connect();
return currentNode;
}
示例6: getCurrentNodes
/**
* Get an observable of the current nodes (the ones that match the current URL)
* We use `publishReplay(1)` because otherwise subscribers will have to wait until the next
* URL change before they receive an emission.
* See above for discussion of using `connect`.
*/
private getCurrentNodes(navigationViews: Observable<NavigationViews>): Observable<CurrentNodes> {
const currentNodes = combineLatest(
navigationViews.map(views => this.computeUrlToNavNodesMap(views)),
this.location.currentPath,
(navMap, url) => {
const urlKey = url.startsWith('api/') ? 'api' : url;
return navMap.get(urlKey) || { '' : { view: '', url: urlKey, nodes: [] }};
})
.publishReplay(1);
currentNodes.connect();
return currentNodes;
}
示例7: getContributors
private getContributors() {
const contributors = this.http.get(contributorsPath)
.map(res => res.json())
// Create group map
.map(contribs => {
const contribMap = new Map<string, Contributor[]>();
Object.keys(contribs).forEach(key => {
const contributor = contribs[key];
const group = contributor.group;
const contribGroup = contribMap[group];
if (contribGroup) {
contribGroup.push(contributor);
} else {
contribMap[group] = [contributor];
}
});
return contribMap;
})
// Flatten group map into sorted group array of sorted contributors
.map(cmap => {
return Object.keys(cmap).map(key => {
const order = knownGroups.indexOf(key);
return {
name: key,
order: order === -1 ? knownGroups.length : order,
contributors: cmap[key].sort(compareContributors)
} as ContributorGroup;
})
.sort(compareGroups);
})
.publishLast();
contributors.connect();
return contributors;
}
示例8: getContributors
private getContributors() {
const contributors = this.http.get(contributorsPath)
.map(res => res.json())
.map(contribs => {
const contribGroups = new Map<string, Contributor[]>();
Object.keys(contribs).forEach(key => {
const contributor = contribs[key];
const group = contributor.group;
const contribGroup = contribGroups[group];
if (contribGroup) {
contribGroup.push(contributor);
} else {
contribGroups[group] = [contributor];
}
});
return contribGroups;
})
.publishLast();
contributors.connect();
return contributors;
}
示例9: getNavigationViews
private getNavigationViews(navigationInfo: Observable<NavigationResponse>): Observable<NavigationViews> {
const navigationViews = navigationInfo.map(response => unpluck(response, '__versionInfo')).publishReplay(1);
navigationViews.connect();
return navigationViews;
}