用途:在 rdc-setup 检测出非 REST/GraphQL 的自定义异步模式后,使用本技能把已有异步函数包装为 Endpoint,使其可在 Data Client 的 hooks 和 controller 中使用。
主要能力:支持包装返回 Promise 的函数、SDK 客户端方法、WebSocket 消息处理器与 IndexedDB 操作;可配置 schema、name、sideEffect、dataExpiryLength、errorExpiryLength、pollFrequency、getOptimisticResponse,并支持自定义 key 函数与 extend() 派生变体。资料给出 Firebase/Firestore、Supabase、IndexedDB、WebSocket 以及带副作用的 mutation 等示例模式。
使用方式:先安装包,例如 npm install @data-client/endpoint(或 yarn add / pnpm add)。用 new Endpoint(fetchFn, { schema, name }) 包装函数;在生产构建中函数名可能被压缩,因此务必显式提供 name。调用时如 useSuspense(getUser, id) 与 ctrl.fetch(createUser, userData),hooks 与 controller 均把 endpoint 作为第一个参数。
限制与缺失:资料未提供定价、平台支持范围或效果数据;具体 API 细节需参考所给 Endpoint 文档链接。后续可应用 rdc-schema 定义 Entity,并应用 rdc-react 或 rdc-vue 接入使用。