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