Runtime API / Interface

RuntimeCompositionReceipt

记录一次 child graph transaction 的最终状态以及新增、复用、移除的 Instance id。

使用说明

调用方至少应检查 status,不能仅以 Promise fulfilled 判断提交成功:

const receipt = await panel.reconcileChildren(specs);
switch (receipt.status) {
case 'committed':
console.log('mounted', receipt.mounted);
console.log('reused', receipt.reused);
console.log('removed', receipt.removed);
break;
case 'cancelled':
case 'superseded':
case 'rolled_back':
case 'rejected':
console.error(receipt.error?.code, receipt.error?.message);
break;
}

mounted、reused、removed 都是 Instance id 数组。业务层需要稳定 child identity 时,继续使用传入的 RuntimeChildSpec.key 或 instance.child(key) 查询。