import { prepareResetJournal, STMEffect } from "@effect/core/stm/STM/definition/primitives" /** * Tries this effect first, and if it fails or retries, tries the other * effect. * * @tsplus pipeable-operator effect/core/stm/STM | * @tsplus static effect/core/stm/STM.Aspects orElse * @tsplus pipeable effect/core/stm/STM orElse */ export function orElse(that: LazyArg>) { return (self: STM): STM => (new STMEffect((journal) => prepareResetJournal(journal)) as STM>) .flatMap((reset) => self .orTry(STM.sync(reset()).zipRight(that())) .catchAll(() => STM.sync(reset()).zipRight(that())) ) }