跳到主要内容

compute_switch_branch_actions()

function compute_switch_branch_actions(readers, branchId): Promise<SwitchVersionActions<EntityType>>;

Defined in: packages/rxdb-plugin-history/src/switch-branch-actions.ts:59

Internal

用给定的仓库算「从当前 active 分支切到 branchId」要落的增删改—— switch_branch_actions 的本体。

Parameters​

ParameterTypeDescription
readersSwitchBranchActionReaders见 SwitchBranchActionReaders
branchIdstring要切换到的分支 id

Returns​

Promise<SwitchVersionActions<EntityType>>

切换分支所需的操作序列

Remarks​

拆出来是给 @aiao/rxdb-plugin-working-tree 的物化屏障用的:屏障要先把来源分支的投影撤掉, 再铺目标分支的快照,而它跑在 switchBranch 的 prepare 里,手上只有事务执行器的仓库—— 绑在适配器上的本地仓库会在同一条连接上等屏障自己那笔事务,死锁。另写一份同义计算, 迟早会在「回滚标记算不算」上与普通切换分叉。