本文整理匯總了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;
}