Open wtianye opened 1 month ago
How to make the updateCounts operation complete in a group.Neither of the following attempts worked
@model("MyApp/Counter") class Counter extends Model({ count: prop(0) }) { @modelAction update(n: number) { this.count = n; } } export async function updateCounts(counter: Counter) { counter.update(111); await f(); counter.update(222); } export function f() { return new Promise((resolve) => { resolve(0); }); } test("1", async () => { const counter = new Counter({}); const undoManager = undoMiddleware(counter); const group = undoManager.createGroup(); await group.continue(async () => { await updateCounts(counter); }); }); test("2", async () => { const counter = new Counter({}); const undoManager = undoMiddleware(counter); await undoManager.withGroupFlow("withGroupFlow", function* () { yield* _await(updateCounts(counter)); }); });
How to make the updateCounts operation complete in a group.Neither of the following attempts worked