@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 21 lines 597 Bytes
Raw
1 import * as Effect from "effect/Effect"
2 import * as TxRef from "effect/TxRef"
3
4 const program = Effect.gen(function*() {
5 const ref = yield* TxRef.make(0)
6
7 yield* Effect.forkChild(Effect.forever(
8 TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
9 ))
10
11 yield* Effect.tx(Effect.gen(function*() {
12 const value = yield* TxRef.get(ref)
13 if (value < 10) {
14 yield* Effect.log(`retry due to value: ${value}`)
15 return yield* Effect.txRetry
16 }
17 yield* Effect.log(`transaction done with value: ${value}`)
18 }))
19 })
20
21 Effect.runPromise(program).catch(console.error)