本文整理汇总了TypeScript中@nteract/messaging.kernelInfoRequest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript kernelInfoRequest函数的具体用法?TypeScript kernelInfoRequest怎么用?TypeScript kernelInfoRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了kernelInfoRequest函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mergeMap
mergeMap(data => {
const session = data.response;
const sessionId = castToSessionId(session.id);
const kernel: RemoteKernelProps = Object.assign({}, session.kernel, {
type: "websocket",
info: null,
sessionId,
cwd,
channels: kernels.connect(
serverConfig,
session.kernel.id,
sessionId
),
kernelSpecName
});
kernel.channels.next(kernelInfoRequest());
return of(
actions.launchKernelSuccessful({
kernel,
kernelRef,
contentRef: action.payload.contentRef,
selectNextKernel: true
})
);
}),
示例2: switchMap
switchMap(({ payload }) => {
const { kernel, kernelName, serverId } = payload;
// Side effect! Get that Kernel Info!
kernel.channel.next(kernelInfoRequest());
return kernel.channel.pipe(
mergeMap((message: JupyterMessage<MessageType, any>) => {
const actionsArray: Array<{
type: string;
payload: {
serverId: string;
kernelName: string;
message?: JupyterMessage;
status?: string;
};
}> = [actions.addKernelMessage({ serverId, kernelName, message })];
switch (message.header.msg_type) {
case "status":
actionsArray.push(
actions.setKernelStatus({
serverId,
kernelName,
status: message.content.execution_state
})
);
break;
case "kernel_info_reply":
actionsArray.push(
actions.setActiveKernelLanguageInfo({
serverId,
kernelName,
languageInfo: message.content.language_info
})
);
break;
case "display_data":
case "execute_result":
case "stream":
case "error":
actionsArray.push(
actions.addKernelOutput({
serverId,
kernelName,
output: {
...message.content,
output_type: message.header.msg_type
}
})
);
break;
default:
break;
}
return from(actionsArray);
})
);
})
示例3: mergeMap
mergeMap(data => {
const session = uuid();
const kernel = Object.assign({}, data.response, {
channel: kernels.connect(
config,
data.response.id,
session
)
});
kernel.channel.next(kernelInfoRequest());
return merge(
of(
actions.activateKernelFulfilled({
serverId,
kernelName,
kernel
})
)
);
})
示例4: async
startKernel: async (parentValue: any, args: StartKernel) => {
const kernel = await launchKernel(args.name);
console.log(`kernel ${args.name}:${kernel.connectionInfo.key} launched`);
// NOTE: we should generate IDs
// We're also setting a session ID within the enchannel-zmq setup, I wonder
// if we should use that
const id = kernel.connectionInfo.key;
messages[id] = [];
kernels[id] = kernel;
const subscription = kernel.channels.subscribe(
(message: JupyterMessage) => {
messages[id].push(message);
}
);
const request = kernelInfoRequest();
messages[id].push(request);
kernel.channels.next(request);
// NOTE: We are going to want to both:
//
// subscription.unsubscribe()
// AND
// kernel.channels.complete()
//
// Within our cleanup code
return {
id,
status: "launched"
};
},