Compensation typedef
A compensation function that undoes a previous operation.
A Compensation is an async function that has no parameters or return value. It's responsible for rolling back the effects of a saga step that has failed. Compensations are invoked in reverse order of step execution (LIFO) when any step fails, ensuring proper cleanup.
Example:
Compensation deleteUserCompensation = () async {
await database.deleteUser(userId);
};
Implementation
@experimental
typedef Compensation = Future<void> Function();