mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-30 19:58:50 +00:00
12 lines
400 B
TypeScript
12 lines
400 B
TypeScript
/**
|
|
* Append one write to a promise chain without letting an earlier rejection
|
|
* poison later edits. The callback is deliberately invoked only when its turn
|
|
* starts, so it can read the latest local state at that moment.
|
|
*/
|
|
export function enqueueSerializedWrite(
|
|
previous: Promise<void>,
|
|
write: () => Promise<void>,
|
|
): Promise<void> {
|
|
return previous.catch(() => undefined).then(write);
|
|
}
|