nocobase-realtime
它能做什么
这项技能指导 NocoBase 3 应用和插件中实时更新的设计。适合希望页面即时显示新数据或处理进度的开发者。
适用场景
- ✓当你希望记录变化时页面自动更新,而不是轮询时。
- ✓当你需要实时显示任务进度或个人通知时。
- ✓当你希望在多个服务器进程之间实时推送日志或更新时。
技能链接
https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/realtime/skills/nocobase-realtime/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我让订单页面在保存新订单时实时更新,而不是每隔几秒重新加载一次。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会先确定哪个数据源是权威来源,然后设置服务器主题和客户端 hooks。实时事件只是简短提示,需要时页面会重新加载真实数据。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
NocoBase Realtime
Use the installed package declarations as the API authority. Applications reuse the host server service through realtimeServiceToken from @nocobase/app-server/realtime and the host browser client through @nocobase/app-client. Do not create a socket or service per component. In a source workspace, this Skill lives under packages/libs/realtime/skills/nocobase-realtime; in generated applications, package Skills are synchronized copies.
Choose the data contract first
Identify the authoritative snapshot endpoint, its access policy, the committed writes that announce changes, and how a disconnected client catches up. Realtime events are transient hints; durable business data remains in its owning service. A successful publication means broker admission, not browser processing. Prefer small invalidations containing a record ID or revision over copying protected record contents into an event.
- Read server integration for topic declaration, resource authorization, transaction boundaries, limits and distributed deployment.
- Read client integration for query correctness, coalesced refresh, readiness, errors, manual retry and cleanup.
- Read business scenarios when choosing between snapshots, cursors, progress and periodic reconciliation.
- Read verification for meaningful acceptance cases and adapter recovery tests.
Boundaries to preserve
Register topics during provider boot and release them during shutdown. Unknown topics are denied. A user topic derives the subscriber's user from the authenticated connection; publishing uses the intended recipient, never a user ID supplied as subscription authority by the browser. Resource families reuse the HTTP endpoint's policy and recheck it on delivery.
Publish only after commit. Treat a notification failure separately from an already successful write; use the domain's durable job/outbox when announcements must be retried. Never skip distributed publication because this process has no subscribers. eventId supports tracing and bounded duplicate suppression; business revisions and persisted cursors own ordering and gap recovery.
Read snapshots after the topic's onReady, including initial subscription and reconnect. Transport onOpen is too early. For TanStack Query use refreshRealtimeQueries, which waits for pre-event reads and follows them with a new read. Return the actual refresh promise to the scheduler so failures and trailing events are observed.
Remove a poll only after identifying all its producers and failure recovery. Time-based expiry, external systems without announcements, bounded initialization waits and failed best-effort publication can still require reconciliation. A healthy WebSocket alone does not prove the snapshot is fresh.
常见问题
实时事件包含全部数据吗?
不包含。事件只是简短提示,持久数据仍保存在原有的服务中。
这是用于 OpenAI 语音功能的吗?
不是。它用于 NocoBase 应用内部的实时更新。
浏览器断开连接后会怎样?
技能涵盖快照恢复机制,使页面在重新连接后能够补齐数据。
详情
作者的原始描述
Design and implement live updates in NocoBase 3 applications and plugins using @nocobase/realtime, host client hooks and authorized server topics. Use for replacing business polling, snapshot recovery, task progress, personal notifications, streamed logs or multi-process fan-out. Not for OpenAI audio Realtime APIs.
repo: nocobase/nocobase
热度
- GitHub 星标
- 25k
- 排名
- #10085
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
nocobase-app-development
25k帮你的智能体为完整的 NocoBase 3 业务应用构建页面、路由、数据、权限和测试。
shadcn
25k帮你的智能体在 Web 项目中查找、添加、修复和美化 shadcn/ui 组件,并使用其官方文档和注册表。
nocobase-app-plugin-development
25k帮你的智能体在现有应用中创建和维护 NocoBase 3 插件,包括服务端、客户端、数据库和注册部分。
nocobase-app-upgrade
25k帮你的智能体把 NocoBase 应用升级到较新的模板版本,引入模板的更改,同时保留你自己的工作。