本文整理汇总了TypeScript中@jupyterlab/apputils.InstanceTracker.find方法的典型用法代码示例。如果您正苦于以下问题:TypeScript InstanceTracker.find方法的具体用法?TypeScript InstanceTracker.find怎么用?TypeScript InstanceTracker.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/apputils.InstanceTracker
的用法示例。
在下文中一共展示了InstanceTracker.find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
execute: args => {
const name = args['name'] as string;
// Check for a running terminal with the given name.
const widget = tracker.find(value => {
return value.session && value.session.name === name || false;
});
if (widget) {
shell.activateById(widget.id);
} else {
// Otherwise, create a new terminal with a given name.
return commands.execute(CommandIDs.createNew, { name });
}
}
示例2:
const getBrowserForPath = (path: string): FileBrowser => {
const driveName = app.serviceManager.contents.driveName(path);
if (driveName) {
let browserForPath = tracker.find(fb => fb.model.driveName === driveName);
if (!browserForPath) {
// warn that no filebrowser could be found for this driveName
console.warn(
`${CommandIDs.navigate} failed to find filebrowser for path: ${path}`
);
return;
}
return browserForPath;
}
// if driveName is empty, assume the main filebrowser
return browser;
};