@ actuallab/ music- rpc
之间的桥梁 @actuallab/fusion 财务报告和审定财务报表
@actuallab/rpc数字 : FusionHub - 计算意识的RPC
中枢, 其客户端代理本地缓存结果, 并在. NET 服务器说时将其丢弃
数值已改变。 这是Fusion的客户端RPC基础设施的等同类型Script
(远程计算服务拦截器, RpcComputeCallType) (中文(简体) ).
这是你想要的包裹 如果你的目标是"呼叫" 组合 从JS/TS客户端计算在.NET服务器上运行的服务,并获得实时更新".
安装
npm install @actuallab/fusion-rpc
无害环境管理首先采用CJS制;船舶自用 .d.ts。拉进 @actuallab/core, (中文(简体) ),
@actuallab/fusion,以及 @actuallab/rpc。 。 。 .
快开始
import { FusionHub, defineComputeService } from '@actuallab/fusion-rpc';
import { RpcClientPeer, RpcPeerStateMonitor } from '@actuallab/rpc';
// 1. Define the service — the name must match the .NET interface name exactly.
const TodoApiDef = defineComputeService('ITodoApi', {
// Compute methods: cached locally, invalidated by the server
Get: { args: ['', ''] }, // (session, id) → TodoItem
ListIds: { args: ['', 0] }, // (session, count) → string[]
GetSummary: { args: [''] }, // (session) → TodoSummary
// Commands: opt out of compute caching
AddOrUpdate: { args: [{}], callTypeId: 0 },
Remove: { args: [{}], callTypeId: 0 },
});
// 2. Hub + peer. The RpcClientPeer ctor starts the connect/reconnect loop.
const hub = new FusionHub();
const peer = new RpcClientPeer(hub, 'ws://localhost:5005/rpc/ws');
hub.addPeer(peer);
// 3. Typed client proxy — addClient is idempotent per (peer, service),
// so every consumer shares one Computed and one invalidation stream.
const api = hub.addClient<ITodoApi>(peer, TodoApiDef);
// 4. Optional: connection status for the UI
const monitor = new RpcPeerStateMonitor(peer);
// Cached until the server invalidates it
const ids = await api.ListIds('~', 10);
把它给
useComputedState 和构成部分
当服务器侧数据发生变化时, 自动刷新 .
无效流
- 客户称计算方法——
FusionHub送来CallType = 1。 。 。 . - 服务器计算、响应
$sys.Ok;客户端在当地缓存结果. - 服务器侧数据更改和服务器侧
Computed<T>无效. - 服务器发送
$sys-c.Invalidate那个电话号码. - 客户端无效其本地复制; 无效级联为每个依赖
@computeMethod财务报告和审定财务报表ComputedState<T>——和回放重击.
一个 Invalidate 到达 在此之前 结果以透明方式重复通话(最多三次尝试)
在连接时). 在断开时,计算复制品自我验证,而不是重新验证,因为
服务器的追踪已经消失 飞行中正常的通话会像往常一样重复.
API 表面
| API 密码 | 说明 |
|---|---|
FusionHub | RpcHub + 计算- 意识代用,无效接线, acceptConnection(ws) 主办单位 |
defineComputeService(name, methods) | 方法默认为 callTypeId: 1 (计算); 使用 callTypeId: 0 用于命令 |
FUSION_CALL_TYPE_ID | 计算调用类型 id (1(中文(简体) ) |
RpcOutboundComputeCall | 包含无效处理的外出呼叫类型 |
页:1
- 撤销. 打电话的
AbortSignal旅行经过AsyncContext(单位:千美元)abortSignalKey(三); 中止发送$sys.Cancel,而由此产生的取消错误永远不会被缓存. - 在节点托管计算服务.
hub.addService(def, impl)包装计算方法和线 无效到$sys-c.Invalidate。使用类@computeMethod成员在任职时 方法互相调用——一个平面对象的活性程序称它们为原始函数并失去 依赖边缘.
文档
@actuallab/fusion-rpc参考文献 ——完整设置示例,无效并重新连接细节- 类型脚本端口概览
- TodoApp 样本( 反应 + Fusion)
许可证
麻省理工学院——见 自由主义。 。 。 .