本文整理汇总了TypeScript中@nteract/core.selectors.kernel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript selectors.kernel方法的具体用法?TypeScript selectors.kernel怎么用?TypeScript selectors.kernel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@nteract/core.selectors
的用法示例。
在下文中一共展示了selectors.kernel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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();
}
示例2:
(state: AppState, kernelRef: KernelRef) => {
const kernel = selectors.kernel(state, { kernelRef });
if (!kernel) {
return "not connected";
} else {
return kernel.status;
}
}
示例3: concatMap
concatMap((action: actions.KillKernelAction) => {
const kernelRef = action.payload.kernelRef;
if (!kernelRef) {
console.warn("tried to kill a kernel without a kernelRef");
return empty();
}
const kernel = selectors.kernel(state$.value, { kernelRef });
if (!kernel) {
// tslint:disable-next-line:no-console
console.warn("tried to kill a kernel that doesn't exist");
return empty();
}
// Ignore the action if the specified kernel is not ZMQ.
if (kernel.type !== "zeromq") {
return empty();
}
const request = shutdownRequest({ restart: false });
// Try to make a shutdown request
// If we don't get a response within X time, force a shutdown
// Either way do the same cleanup
const shutDownHandling = kernel.channels.pipe(
childOf(request),
ofMessageType("shutdown_reply"),
first(),
// If we got a reply, great! :)
map((msg: { content: { restart: boolean } }) =>
actions.shutdownReplySucceeded({ content: msg.content, kernelRef })
),
// If we don't get a response within 2s, assume failure :(
timeout(1000 * 2),
catchError(err =>
of(actions.shutdownReplyTimedOut({ error: err, kernelRef }))
),
mergeMap(resultingAction => {
// End all communication on the channels
kernel.channels.complete();
if (kernel.spawn) {
killSpawn(kernel.spawn);
}
return merge(
// Pass on our intermediate action (whether or not kernel ACK'd shutdown request promptly)
of(resultingAction),
// Indicate overall success (channels cleaned up)
of(
actions.killKernelSuccessful({
kernelRef
})
),
// Inform about the state
of(
actions.setExecutionState({
kernelStatus: "shutting down",
kernelRef
})
)
);
}),
catchError(err =>
// Catch all, in case there were other errors here
of(actions.killKernelFailed({ error: err, kernelRef }))
)
);
// On subscription, send the message
return new Observable(observer => {
const subscription = shutDownHandling.subscribe(observer);
kernel.channels.next(request);
return subscription;
});
})