foreign.session returns a handle from ordinary kernel/cell tables; view consumes only the 会话 binding. Sessions live in host foreign_doc. Without 会话, view cells run stateless one-shot. Add /api/session/clear and a Clear outputs button for every view page; clearing keeps persistent kernel state.
683 B
683 B
title: notebook shared state import foreign:lib/foreign.mq.md
main
内核表 =
| 名称 | 语言 | 命令 | 说明 |
|---|---|---|---|
| 分析 | node | 共享状态的内核 | |
| 绘图 | node | 隔离的内核 |
会话表 =
| 单元 | 内核 | 说明 |
|---|---|---|
| 设置 | 分析 | 写入共享变量 |
| 读取 | 分析 | 读取共享变量 |
| 隔离 | 绘图 | 看不到 shared |
会话 = > foreign.session kernels=内核表 cells=会话表
设置 =
let shared = 41;
读取 =
console.log(shared + 1);
隔离 =
console.log(typeof shared === "undefined" ? "isolated" : "leaked");