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