跳到主要内容

gateExternalNotify()

function gateExternalNotify<TResult>(request, notify): TResult;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/external-notify-gate.ts:70

判定一次外部更新通知,放行时才执行通知体

Type Parameters​

Type ParameterDescription
TResult通知体的返回类型;门禁原样透传,不做任何包装

Parameters​

ParameterTypeDescription
requestExternalNotifyGateRequest实体名、目标类与能力位
notify() => TResult还没被调用的通知体

Returns​

TResult

notify() 的返回值本身

Throws​

WorkingTreeWriteRejectedError 目标是版本化业务实体且已启用提交能力时抛出; 此时 notify 一次都不会被调用

Remarks​

判定不在这里另写一份,直接问 classifyWriteEntrance。送进去的 operation / columns / untrackedFields 是矩阵要求的形参而不是判据:行 11 在版本化目标上 无条件落 reject,三者取什么值都到不了看它们的那一步(见 classifyVersionedTarget)。 在这里按「改了哪些列」做近似取舍,就是矩阵之外的第二份判定。

核心不直接调本函数,它调的是捕获钩子上的同名转交门;那一层把实体身份翻成 targetClass 之后才落到这里。核心侧因此一个捕获语义都不认识,而判定仍只有这一份。

Example​

// 插件的捕获运行时——归类与能力位都在它手上
gateExternalNotify<T>(entityName: string, namespace: string | undefined, notify: () => T): T {
return gateExternalNotify(
{ entityName, targetClass: this.targetClassOf(entityName, namespace), capabilityEnabled: true },
notify
);
}