本文整理匯總了TypeScript中@nteract/core.createKernelRef函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createKernelRef函數的具體用法?TypeScript createKernelRef怎麽用?TypeScript createKernelRef使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createKernelRef函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: dispatchNewKernel
export function dispatchNewKernel(
ownProps: { contentRef: ContentRef },
store: DesktopStore,
_evt: Event,
kernelSpec: KernelSpec
) {
const state = store.getState();
const filepath = selectors.filepath(state, ownProps);
const cwd =
filepath !== null
? path.dirname(path.resolve(filepath))
: cwdKernelFallback();
// Create a brand new kernel
const kernelRef = createKernelRef();
store.dispatch(
actions.launchKernel({
kernelSpec,
cwd,
selectNextKernel: true,
kernelRef,
contentRef: ownProps.contentRef
})
);
}
示例2: cwdKernelFallback
index => {
if (index === 0) {
const state = store.getState();
const oldKernelRef = selectors.kernelRefByContentRef(state, ownProps);
if (!oldKernelRef) {
console.error("kernel not available for relaunch");
return;
}
const kernel = selectors.kernel(state, { kernelRef: oldKernelRef });
if (!kernel) {
console.error("kernel not available for relaunch");
return;
}
const cwd = filepath
? path.dirname(path.resolve(filepath))
: cwdKernelFallback();
// Create a brand new kernel
const kernelRef = createKernelRef();
store.dispatch(
actions.launchKernelByName({
kernelSpecName: kernel.kernelSpecName,
cwd,
selectNextKernel: true,
kernelRef,
contentRef: ownProps.contentRef
})
);
}
resolve();
}
示例3: dispatchNewNotebook
export function dispatchNewNotebook(
ownProps: { contentRef: ContentRef },
store: DesktopStore,
event: Event,
kernelSpec: KernelSpec
) {
// It's a brand new notebook so we create a kernelRef for it
const kernelRef = createKernelRef();
store.dispatch(
// for desktop, we _can_ assume this has no path except for living in `cwd`
// which I suppose _could_ be called `${cwd}/UntitledN.ipynb`
// for jupyter extension, we _would_ call this `${cwd}/UntitledN.ipynb`
actions.newNotebook({
kernelSpec,
cwd: cwdKernelFallback(),
kernelRef,
contentRef: ownProps.contentRef
})
);
}
示例4: dispatchLoad
export function dispatchLoad(
ownProps: { contentRef: ContentRef },
store: DesktopStore,
event: Event,
filepath: string
) {
// We are loading a new document so we will create a kernelRef
const kernelRef = createKernelRef();
// Remove the protocol string from requests originating from
// another notebook
filepath = filepath.replace("file://", "");
store.dispatch(
actions.fetchContent({
filepath,
params: {},
kernelRef,
contentRef: ownProps.contentRef
})
);
}