例如,在FluidFramework/examples/data-objects/badge/src/BadgeClient.tsx:中
const changeSelectedOption = (newItem: IBadgeType): void => {
if (newItem.key !== model.currentCell.get().key) {
const len = model.historySequence.getItemCount();
model.historySequence.insert(len, [
{
value: newItem,
timestamp: new Date(),
},
]);
model.currentCell.set(newItem);
}
};历史插入操作是否总是与单元格设置操作一起成功或失败?
发布于 2020-09-14 12:20:30
Fluid不支持传统意义上的事务,但Fluid确实有"Group Ops“。可以使用ContainerRuntime上的orderSequentially应用编程接口创建这些应用程序。一些DDS对这个容器级API有一个包装器。
组操作允许您将一组operations打包到一条消息中,以便流体订购服务按顺序将这些操作添加到Total Order Broadcast中。
Ops只能在一个容器内分组,因为这是整个订单广播的边界。操作可以在一个容器内跨DDS分组。这仍然不同于事务,因为我们不保证在后面的操作无效的情况下回滚之前的操作。
您可以在Sequence DDS中看到一个示例。
下面,我们将在一个组op中为"hello“和"world”提交两个op,确保helloworld将在没有交错输入的情况下一次性提交。
const op1 = {
pos: 0,
seg: "hello",
type: MergeTreeDeltaType.INSERT,
}
const op2 = {
pos: 5,
seg: "world"
type: MergeTreeDeltaType.INSERT,
}
const groupOp = {
ops: [op1, op2],
type: MergeTreeDeltaType.GROUP,
}
sharedString.groupOperation(groupOp);ProseMirror fluid object有更深入的代码
发布于 2020-09-18 05:06:33
不是事务,但它支持批处理。批处理保证不会在批处理中的操作之间交错任何其他操作。您可以使用orderSequentially Api创建批处理
https://stackoverflow.com/questions/63877661
复制相似问题