@typed/fx 2.0.0-beta.0 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +58 -21
- package/dist/Fx/Fx.d.ts +371 -19
- package/dist/Fx/Fx.d.ts.map +1 -1
- package/dist/Fx/Fx.js +37 -6
- package/dist/Fx/TypeId.d.ts +52 -6
- package/dist/Fx/TypeId.d.ts.map +1 -1
- package/dist/Fx/TypeId.js +41 -4
- package/dist/Fx/combinators/additive.d.ts +245 -0
- package/dist/Fx/combinators/additive.d.ts.map +1 -0
- package/dist/Fx/combinators/additive.js +243 -0
- package/dist/Fx/combinators/catch.d.ts +246 -12
- package/dist/Fx/combinators/catch.d.ts.map +1 -1
- package/dist/Fx/combinators/catch.js +236 -12
- package/dist/Fx/combinators/causes.d.ts +25 -2
- package/dist/Fx/combinators/causes.d.ts.map +1 -1
- package/dist/Fx/combinators/causes.js +25 -2
- package/dist/Fx/combinators/changesWithEffect.d.ts +40 -0
- package/dist/Fx/combinators/changesWithEffect.d.ts.map +1 -0
- package/dist/Fx/combinators/changesWithEffect.js +48 -0
- package/dist/Fx/combinators/compact.d.ts +18 -1
- package/dist/Fx/combinators/compact.d.ts.map +1 -1
- package/dist/Fx/combinators/compact.js +18 -1
- package/dist/Fx/combinators/concatMap.d.ts +86 -0
- package/dist/Fx/combinators/concatMap.d.ts.map +1 -0
- package/dist/Fx/combinators/concatMap.js +86 -0
- package/dist/Fx/combinators/continueWith.d.ts +113 -5
- package/dist/Fx/combinators/continueWith.d.ts.map +1 -1
- package/dist/Fx/combinators/continueWith.js +113 -5
- package/dist/Fx/combinators/debounce.d.ts +34 -0
- package/dist/Fx/combinators/debounce.d.ts.map +1 -0
- package/dist/Fx/combinators/debounce.js +35 -0
- package/dist/Fx/combinators/delay.d.ts +36 -0
- package/dist/Fx/combinators/delay.d.ts.map +1 -0
- package/dist/Fx/combinators/delay.js +33 -0
- package/dist/Fx/combinators/dropUntil.d.ts +71 -0
- package/dist/Fx/combinators/dropUntil.d.ts.map +1 -0
- package/dist/Fx/combinators/dropUntil.js +65 -0
- package/dist/Fx/combinators/during.d.ts +38 -0
- package/dist/Fx/combinators/during.d.ts.map +1 -0
- package/dist/Fx/combinators/during.js +85 -0
- package/dist/Fx/combinators/ensuring.d.ts +34 -4
- package/dist/Fx/combinators/ensuring.d.ts.map +1 -1
- package/dist/Fx/combinators/ensuring.js +34 -4
- package/dist/Fx/combinators/exhaustLatestMap.d.ts +41 -5
- package/dist/Fx/combinators/exhaustLatestMap.d.ts.map +1 -1
- package/dist/Fx/combinators/exhaustLatestMap.js +41 -5
- package/dist/Fx/combinators/exhaustLatestMapEffect.d.ts +40 -4
- package/dist/Fx/combinators/exhaustLatestMapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/exhaustLatestMapEffect.js +40 -4
- package/dist/Fx/combinators/exhaustMap.d.ts +38 -1
- package/dist/Fx/combinators/exhaustMap.d.ts.map +1 -1
- package/dist/Fx/combinators/exhaustMap.js +38 -1
- package/dist/Fx/combinators/exhaustMapEffect.d.ts +33 -1
- package/dist/Fx/combinators/exhaustMapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/exhaustMapEffect.js +33 -1
- package/dist/Fx/combinators/exit.d.ts +23 -2
- package/dist/Fx/combinators/exit.d.ts.map +1 -1
- package/dist/Fx/combinators/exit.js +23 -2
- package/dist/Fx/combinators/filter.d.ts +17 -1
- package/dist/Fx/combinators/filter.d.ts.map +1 -1
- package/dist/Fx/combinators/filter.js +17 -1
- package/dist/Fx/combinators/filterEffect.d.ts +22 -1
- package/dist/Fx/combinators/filterEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/filterEffect.js +22 -1
- package/dist/Fx/combinators/filterMap.d.ts +20 -1
- package/dist/Fx/combinators/filterMap.d.ts.map +1 -1
- package/dist/Fx/combinators/filterMap.js +20 -1
- package/dist/Fx/combinators/filterMapEffect.d.ts +21 -1
- package/dist/Fx/combinators/filterMapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/filterMapEffect.js +21 -1
- package/dist/Fx/combinators/filterMapLoop.d.ts +20 -1
- package/dist/Fx/combinators/filterMapLoop.d.ts.map +1 -1
- package/dist/Fx/combinators/filterMapLoop.js +20 -1
- package/dist/Fx/combinators/filterMapLoopCause.d.ts +21 -1
- package/dist/Fx/combinators/filterMapLoopCause.d.ts.map +1 -1
- package/dist/Fx/combinators/filterMapLoopCause.js +21 -1
- package/dist/Fx/combinators/filterMapLoopCauseEffect.d.ts +21 -1
- package/dist/Fx/combinators/filterMapLoopCauseEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/filterMapLoopCauseEffect.js +21 -1
- package/dist/Fx/combinators/filterMapLoopEffect.d.ts +21 -1
- package/dist/Fx/combinators/filterMapLoopEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/filterMapLoopEffect.js +21 -1
- package/dist/Fx/combinators/flatMap.d.ts +50 -5
- package/dist/Fx/combinators/flatMap.d.ts.map +1 -1
- package/dist/Fx/combinators/flatMap.js +36 -3
- package/dist/Fx/combinators/flatMapConcurrently.d.ts +51 -4
- package/dist/Fx/combinators/flatMapConcurrently.d.ts.map +1 -1
- package/dist/Fx/combinators/flatMapConcurrently.js +51 -4
- package/dist/Fx/combinators/flatMapConcurrentlyEffect.d.ts +48 -4
- package/dist/Fx/combinators/flatMapConcurrentlyEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/flatMapConcurrentlyEffect.js +40 -2
- package/dist/Fx/combinators/flatMapEffect.d.ts +46 -4
- package/dist/Fx/combinators/flatMapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/flatMapEffect.js +32 -2
- package/dist/Fx/combinators/flip.d.ts +34 -2
- package/dist/Fx/combinators/flip.d.ts.map +1 -1
- package/dist/Fx/combinators/flip.js +34 -2
- package/dist/Fx/combinators/gen.d.ts +29 -10
- package/dist/Fx/combinators/gen.d.ts.map +1 -1
- package/dist/Fx/combinators/gen.js +28 -4
- package/dist/Fx/combinators/genScoped.d.ts +33 -10
- package/dist/Fx/combinators/genScoped.d.ts.map +1 -1
- package/dist/Fx/combinators/genScoped.js +31 -3
- package/dist/Fx/combinators/grouped.d.ts +89 -0
- package/dist/Fx/combinators/grouped.d.ts.map +1 -0
- package/dist/Fx/combinators/grouped.js +146 -0
- package/dist/Fx/combinators/index.d.ts +45 -0
- package/dist/Fx/combinators/index.d.ts.map +1 -1
- package/dist/Fx/combinators/index.js +45 -0
- package/dist/Fx/combinators/keyed.d.ts +124 -10
- package/dist/Fx/combinators/keyed.d.ts.map +1 -1
- package/dist/Fx/combinators/keyed.js +69 -11
- package/dist/Fx/combinators/loop.d.ts +17 -1
- package/dist/Fx/combinators/loop.d.ts.map +1 -1
- package/dist/Fx/combinators/loop.js +17 -1
- package/dist/Fx/combinators/loopCause.d.ts +18 -1
- package/dist/Fx/combinators/loopCause.d.ts.map +1 -1
- package/dist/Fx/combinators/loopCause.js +18 -1
- package/dist/Fx/combinators/loopCauseEffect.d.ts +19 -1
- package/dist/Fx/combinators/loopCauseEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/loopCauseEffect.js +19 -1
- package/dist/Fx/combinators/loopEffect.d.ts +24 -1
- package/dist/Fx/combinators/loopEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/loopEffect.js +24 -1
- package/dist/Fx/combinators/map.d.ts +46 -1
- package/dist/Fx/combinators/map.d.ts.map +1 -1
- package/dist/Fx/combinators/map.js +43 -1
- package/dist/Fx/combinators/mapBoth.d.ts +40 -0
- package/dist/Fx/combinators/mapBoth.d.ts.map +1 -0
- package/dist/Fx/combinators/mapBoth.js +33 -0
- package/dist/Fx/combinators/mapEffect.d.ts +25 -1
- package/dist/Fx/combinators/mapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/mapEffect.js +25 -1
- package/dist/Fx/combinators/mapError.d.ts +33 -0
- package/dist/Fx/combinators/mapError.d.ts.map +1 -0
- package/dist/Fx/combinators/mapError.js +32 -0
- package/dist/Fx/combinators/mergeAll.d.ts +35 -1
- package/dist/Fx/combinators/mergeAll.d.ts.map +1 -1
- package/dist/Fx/combinators/mergeAll.js +35 -1
- package/dist/Fx/combinators/mergeOrdered.d.ts +36 -4
- package/dist/Fx/combinators/mergeOrdered.d.ts.map +1 -1
- package/dist/Fx/combinators/mergeOrdered.js +68 -14
- package/dist/Fx/combinators/onError.d.ts +34 -4
- package/dist/Fx/combinators/onError.d.ts.map +1 -1
- package/dist/Fx/combinators/onError.js +34 -4
- package/dist/Fx/combinators/onExit.d.ts +29 -3
- package/dist/Fx/combinators/onExit.d.ts.map +1 -1
- package/dist/Fx/combinators/onExit.js +29 -3
- package/dist/Fx/combinators/onInterrupt.d.ts +49 -4
- package/dist/Fx/combinators/onInterrupt.d.ts.map +1 -1
- package/dist/Fx/combinators/onInterrupt.js +49 -4
- package/dist/Fx/combinators/pairwise.d.ts +28 -0
- package/dist/Fx/combinators/pairwise.d.ts.map +1 -0
- package/dist/Fx/combinators/pairwise.js +31 -0
- package/dist/Fx/combinators/provide.d.ts +162 -8
- package/dist/Fx/combinators/provide.d.ts.map +1 -1
- package/dist/Fx/combinators/provide.js +154 -6
- package/dist/Fx/combinators/race.d.ts +92 -0
- package/dist/Fx/combinators/race.d.ts.map +1 -0
- package/dist/Fx/combinators/race.js +149 -0
- package/dist/Fx/combinators/repeat.d.ts +41 -0
- package/dist/Fx/combinators/repeat.d.ts.map +1 -0
- package/dist/Fx/combinators/repeat.js +57 -0
- package/dist/Fx/combinators/result.d.ts +45 -0
- package/dist/Fx/combinators/result.d.ts.map +1 -0
- package/dist/Fx/combinators/result.js +46 -0
- package/dist/Fx/combinators/retry.d.ts +53 -0
- package/dist/Fx/combinators/retry.d.ts.map +1 -0
- package/dist/Fx/combinators/retry.js +71 -0
- package/dist/Fx/combinators/sample.d.ts +31 -0
- package/dist/Fx/combinators/sample.d.ts.map +1 -0
- package/dist/Fx/combinators/sample.js +42 -0
- package/dist/Fx/combinators/scan.d.ts +72 -0
- package/dist/Fx/combinators/scan.d.ts.map +1 -0
- package/dist/Fx/combinators/scan.js +77 -0
- package/dist/Fx/combinators/since.d.ts +30 -0
- package/dist/Fx/combinators/since.d.ts.map +1 -0
- package/dist/Fx/combinators/since.js +39 -0
- package/dist/Fx/combinators/skip.d.ts +45 -1
- package/dist/Fx/combinators/skip.d.ts.map +1 -1
- package/dist/Fx/combinators/skip.js +43 -1
- package/dist/Fx/combinators/skipRepeats.d.ts +17 -1
- package/dist/Fx/combinators/skipRepeats.d.ts.map +1 -1
- package/dist/Fx/combinators/skipRepeats.js +17 -1
- package/dist/Fx/combinators/skipRepeatsWith.d.ts +18 -1
- package/dist/Fx/combinators/skipRepeatsWith.d.ts.map +1 -1
- package/dist/Fx/combinators/skipRepeatsWith.js +18 -1
- package/dist/Fx/combinators/skipWhile.d.ts +117 -0
- package/dist/Fx/combinators/skipWhile.d.ts.map +1 -0
- package/dist/Fx/combinators/skipWhile.js +134 -0
- package/dist/Fx/combinators/slice.d.ts +97 -2
- package/dist/Fx/combinators/slice.d.ts.map +1 -1
- package/dist/Fx/combinators/slice.js +45 -1
- package/dist/Fx/combinators/switchMap.d.ts +39 -1
- package/dist/Fx/combinators/switchMap.d.ts.map +1 -1
- package/dist/Fx/combinators/switchMap.js +43 -5
- package/dist/Fx/combinators/switchMapEffect.d.ts +38 -1
- package/dist/Fx/combinators/switchMapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/switchMapEffect.js +38 -1
- package/dist/Fx/combinators/take.d.ts +46 -1
- package/dist/Fx/combinators/take.d.ts.map +1 -1
- package/dist/Fx/combinators/take.js +44 -1
- package/dist/Fx/combinators/takeUntil.d.ts +62 -2
- package/dist/Fx/combinators/takeUntil.d.ts.map +1 -1
- package/dist/Fx/combinators/takeUntil.js +62 -2
- package/dist/Fx/combinators/takeWhile.d.ts +60 -0
- package/dist/Fx/combinators/takeWhile.d.ts.map +1 -0
- package/dist/Fx/combinators/takeWhile.js +54 -0
- package/dist/Fx/combinators/tapEffect.d.ts +17 -1
- package/dist/Fx/combinators/tapEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/tapEffect.js +17 -1
- package/dist/Fx/combinators/throttle.d.ts +79 -0
- package/dist/Fx/combinators/throttle.d.ts.map +1 -0
- package/dist/Fx/combinators/throttle.js +99 -0
- package/dist/Fx/combinators/timeout.d.ts +76 -0
- package/dist/Fx/combinators/timeout.d.ts.map +1 -0
- package/dist/Fx/combinators/timeout.js +110 -0
- package/dist/Fx/combinators/tuple.d.ts +32 -2
- package/dist/Fx/combinators/tuple.d.ts.map +1 -1
- package/dist/Fx/combinators/tuple.js +36 -5
- package/dist/Fx/combinators/until.d.ts +27 -0
- package/dist/Fx/combinators/until.d.ts.map +1 -0
- package/dist/Fx/combinators/until.js +56 -0
- package/dist/Fx/combinators/unwrap.d.ts +31 -2
- package/dist/Fx/combinators/unwrap.d.ts.map +1 -1
- package/dist/Fx/combinators/unwrap.js +30 -1
- package/dist/Fx/combinators/unwrapScoped.d.ts +34 -1
- package/dist/Fx/combinators/unwrapScoped.d.ts.map +1 -1
- package/dist/Fx/combinators/unwrapScoped.js +34 -1
- package/dist/Fx/combinators/when.d.ts +37 -2
- package/dist/Fx/combinators/when.d.ts.map +1 -1
- package/dist/Fx/combinators/when.js +38 -3
- package/dist/Fx/combinators/withLatestFrom.d.ts +58 -0
- package/dist/Fx/combinators/withLatestFrom.d.ts.map +1 -0
- package/dist/Fx/combinators/withLatestFrom.js +68 -0
- package/dist/Fx/combinators/withSpan.d.ts +35 -1
- package/dist/Fx/combinators/withSpan.d.ts.map +1 -1
- package/dist/Fx/combinators/withSpan.js +34 -3
- package/dist/Fx/combinators/zip.d.ts +135 -0
- package/dist/Fx/combinators/zip.d.ts.map +1 -0
- package/dist/Fx/combinators/zip.js +160 -0
- package/dist/Fx/constructors/at.d.ts +23 -3
- package/dist/Fx/constructors/at.d.ts.map +1 -1
- package/dist/Fx/constructors/at.js +21 -1
- package/dist/Fx/constructors/die.d.ts +22 -1
- package/dist/Fx/constructors/die.d.ts.map +1 -1
- package/dist/Fx/constructors/die.js +22 -1
- package/dist/Fx/constructors/empty.d.ts +19 -1
- package/dist/Fx/constructors/empty.d.ts.map +1 -1
- package/dist/Fx/constructors/empty.js +19 -1
- package/dist/Fx/constructors/fail.d.ts +22 -1
- package/dist/Fx/constructors/fail.d.ts.map +1 -1
- package/dist/Fx/constructors/fail.js +22 -1
- package/dist/Fx/constructors/failCause.d.ts +23 -1
- package/dist/Fx/constructors/failCause.d.ts.map +1 -1
- package/dist/Fx/constructors/failCause.js +23 -1
- package/dist/Fx/constructors/fn.d.ts +116 -16
- package/dist/Fx/constructors/fn.d.ts.map +1 -1
- package/dist/Fx/constructors/fn.js +36 -0
- package/dist/Fx/constructors/fromEffect.d.ts +45 -3
- package/dist/Fx/constructors/fromEffect.d.ts.map +1 -1
- package/dist/Fx/constructors/fromEffect.js +45 -3
- package/dist/Fx/constructors/fromFailures.d.ts +25 -1
- package/dist/Fx/constructors/fromFailures.d.ts.map +1 -1
- package/dist/Fx/constructors/fromFailures.js +25 -1
- package/dist/Fx/constructors/fromIterable.d.ts +23 -1
- package/dist/Fx/constructors/fromIterable.d.ts.map +1 -1
- package/dist/Fx/constructors/fromIterable.js +23 -1
- package/dist/Fx/constructors/fromSchedule.d.ts +26 -1
- package/dist/Fx/constructors/fromSchedule.d.ts.map +1 -1
- package/dist/Fx/constructors/fromSchedule.js +28 -3
- package/dist/Fx/constructors/index.d.ts +2 -1
- package/dist/Fx/constructors/index.d.ts.map +1 -1
- package/dist/Fx/constructors/index.js +2 -1
- package/dist/Fx/constructors/interrupt.d.ts +22 -2
- package/dist/Fx/constructors/interrupt.d.ts.map +1 -1
- package/dist/Fx/constructors/interrupt.js +22 -2
- package/dist/Fx/constructors/make.d.ts +151 -4
- package/dist/Fx/constructors/make.d.ts.map +1 -1
- package/dist/Fx/constructors/make.js +60 -7
- package/dist/Fx/constructors/periodic.d.ts +31 -2
- package/dist/Fx/constructors/periodic.d.ts.map +1 -1
- package/dist/Fx/constructors/periodic.js +30 -1
- package/dist/Fx/constructors/succeed.d.ts +79 -7
- package/dist/Fx/constructors/succeed.d.ts.map +1 -1
- package/dist/Fx/constructors/succeed.js +79 -7
- package/dist/Fx/constructors/suspend.d.ts +28 -0
- package/dist/Fx/constructors/suspend.d.ts.map +1 -1
- package/dist/Fx/constructors/suspend.js +28 -0
- package/dist/Fx/constructors/sync.d.ts +32 -0
- package/dist/Fx/constructors/sync.d.ts.map +1 -0
- package/dist/Fx/constructors/sync.js +32 -0
- package/dist/Fx/internal/DeferredRef.d.ts +259 -7
- package/dist/Fx/internal/DeferredRef.d.ts.map +1 -1
- package/dist/Fx/internal/DeferredRef.js +260 -9
- package/dist/Fx/internal/UnionToTuple.d.ts +22 -0
- package/dist/Fx/internal/UnionToTuple.d.ts.map +1 -1
- package/dist/Fx/internal/diff.d.ts +586 -0
- package/dist/Fx/internal/diff.d.ts.map +1 -1
- package/dist/Fx/internal/diff.js +120 -9
- package/dist/Fx/internal/effectableEvaluateKey.d.ts +30 -0
- package/dist/Fx/internal/effectableEvaluateKey.d.ts.map +1 -0
- package/dist/Fx/internal/effectableEvaluateKey.js +29 -0
- package/dist/Fx/internal/effectableWithOverride.d.ts +55 -0
- package/dist/Fx/internal/effectableWithOverride.d.ts.map +1 -0
- package/dist/Fx/internal/effectableWithOverride.js +46 -0
- package/dist/Fx/internal/equivalence.d.ts +29 -0
- package/dist/Fx/internal/equivalence.d.ts.map +1 -1
- package/dist/Fx/internal/equivalence.js +29 -0
- package/dist/Fx/internal/multicast.d.ts +145 -2
- package/dist/Fx/internal/multicast.d.ts.map +1 -1
- package/dist/Fx/internal/multicast.js +146 -4
- package/dist/Fx/internal/ring-buffer.d.ts +149 -0
- package/dist/Fx/internal/ring-buffer.d.ts.map +1 -1
- package/dist/Fx/internal/ring-buffer.js +155 -0
- package/dist/Fx/internal/scope.d.ts +184 -0
- package/dist/Fx/internal/scope.d.ts.map +1 -1
- package/dist/Fx/internal/scope.js +150 -0
- package/dist/Fx/internal/yieldable.d.ts +117 -2
- package/dist/Fx/internal/yieldable.d.ts.map +1 -1
- package/dist/Fx/internal/yieldable.js +86 -3
- package/dist/Fx/run/collect.d.ts +93 -4
- package/dist/Fx/run/collect.d.ts.map +1 -1
- package/dist/Fx/run/collect.js +94 -5
- package/dist/Fx/run/first.d.ts +23 -1
- package/dist/Fx/run/first.d.ts.map +1 -1
- package/dist/Fx/run/first.js +23 -1
- package/dist/Fx/run/fork.d.ts +52 -2
- package/dist/Fx/run/fork.d.ts.map +1 -1
- package/dist/Fx/run/fork.js +52 -2
- package/dist/Fx/run/observe.d.ts +112 -4
- package/dist/Fx/run/observe.d.ts.map +1 -1
- package/dist/Fx/run/observe.js +137 -16
- package/dist/Fx/run/runPromise.d.ts +45 -2
- package/dist/Fx/run/runPromise.d.ts.map +1 -1
- package/dist/Fx/run/runPromise.js +45 -2
- package/dist/Fx/stream.d.ts +92 -0
- package/dist/Fx/stream.d.ts.map +1 -1
- package/dist/Fx/stream.js +60 -1
- package/dist/Push/Push.d.ts +1286 -98
- package/dist/Push/Push.d.ts.map +1 -1
- package/dist/Push/Push.js +1074 -88
- package/dist/RefArray.d.ts +2 -0
- package/dist/RefArray.d.ts.map +1 -0
- package/dist/RefArray.js +1 -0
- package/dist/RefBigDecimal.d.ts +2 -0
- package/dist/RefBigDecimal.d.ts.map +1 -0
- package/dist/RefBigDecimal.js +1 -0
- package/dist/RefBigInt.d.ts +2 -0
- package/dist/RefBigInt.d.ts.map +1 -0
- package/dist/RefBigInt.js +1 -0
- package/dist/RefBoolean.d.ts +2 -0
- package/dist/RefBoolean.d.ts.map +1 -0
- package/dist/RefBoolean.js +1 -0
- package/dist/RefCause.d.ts +2 -0
- package/dist/RefCause.d.ts.map +1 -0
- package/dist/RefCause.js +1 -0
- package/dist/RefChunk.d.ts +2 -0
- package/dist/RefChunk.d.ts.map +1 -0
- package/dist/RefChunk.js +1 -0
- package/dist/RefDateTime.d.ts +2 -0
- package/dist/RefDateTime.d.ts.map +1 -0
- package/dist/RefDateTime.js +1 -0
- package/dist/RefDuration.d.ts +2 -0
- package/dist/RefDuration.d.ts.map +1 -0
- package/dist/RefDuration.js +1 -0
- package/dist/RefGraph.d.ts +2 -0
- package/dist/RefGraph.d.ts.map +1 -0
- package/dist/RefGraph.js +1 -0
- package/dist/RefHashMap.d.ts +2 -0
- package/dist/RefHashMap.d.ts.map +1 -0
- package/dist/RefHashMap.js +1 -0
- package/dist/RefHashRing.d.ts +2 -0
- package/dist/RefHashRing.d.ts.map +1 -0
- package/dist/RefHashRing.js +1 -0
- package/dist/RefHashSet.d.ts +2 -0
- package/dist/RefHashSet.d.ts.map +1 -0
- package/dist/RefHashSet.js +1 -0
- package/dist/RefIterable.d.ts +2 -0
- package/dist/RefIterable.d.ts.map +1 -0
- package/dist/RefIterable.js +1 -0
- package/dist/RefOption.d.ts +2 -0
- package/dist/RefOption.d.ts.map +1 -0
- package/dist/RefOption.js +1 -0
- package/dist/RefRecord.d.ts +2 -0
- package/dist/RefRecord.d.ts.map +1 -0
- package/dist/RefRecord.js +1 -0
- package/dist/RefResult.d.ts +2 -0
- package/dist/RefResult.d.ts.map +1 -0
- package/dist/RefResult.js +1 -0
- package/dist/RefString.d.ts +2 -0
- package/dist/RefString.d.ts.map +1 -0
- package/dist/RefString.js +1 -0
- package/dist/RefStruct.d.ts +2 -0
- package/dist/RefStruct.d.ts.map +1 -0
- package/dist/RefStruct.js +1 -0
- package/dist/RefSubject/Hydration.d.ts +504 -0
- package/dist/RefSubject/Hydration.d.ts.map +1 -0
- package/dist/RefSubject/Hydration.js +300 -0
- package/dist/RefSubject/RefArray.d.ts +382 -35
- package/dist/RefSubject/RefArray.d.ts.map +1 -1
- package/dist/RefSubject/RefArray.js +374 -40
- package/dist/RefSubject/RefBigDecimal.d.ts +241 -21
- package/dist/RefSubject/RefBigDecimal.d.ts.map +1 -1
- package/dist/RefSubject/RefBigDecimal.js +229 -20
- package/dist/RefSubject/RefBigInt.d.ts +181 -16
- package/dist/RefSubject/RefBigInt.d.ts.map +1 -1
- package/dist/RefSubject/RefBigInt.js +169 -15
- package/dist/RefSubject/RefBoolean.d.ts +181 -16
- package/dist/RefSubject/RefBoolean.d.ts.map +1 -1
- package/dist/RefSubject/RefBoolean.js +169 -15
- package/dist/RefSubject/RefCause.d.ts +133 -12
- package/dist/RefSubject/RefCause.d.ts.map +1 -1
- package/dist/RefSubject/RefCause.js +121 -11
- package/dist/RefSubject/RefChunk.d.ts +481 -76
- package/dist/RefSubject/RefChunk.d.ts.map +1 -1
- package/dist/RefSubject/RefChunk.js +471 -75
- package/dist/RefSubject/RefDateTime.d.ts +137 -16
- package/dist/RefSubject/RefDateTime.d.ts.map +1 -1
- package/dist/RefSubject/RefDateTime.js +122 -12
- package/dist/RefSubject/RefDuration.d.ts +169 -15
- package/dist/RefSubject/RefDuration.d.ts.map +1 -1
- package/dist/RefSubject/RefDuration.js +157 -14
- package/dist/RefSubject/RefGraph.d.ts +349 -35
- package/dist/RefSubject/RefGraph.d.ts.map +1 -1
- package/dist/RefSubject/RefGraph.js +334 -32
- package/dist/RefSubject/RefHashMap.d.ts +323 -28
- package/dist/RefSubject/RefHashMap.d.ts.map +1 -1
- package/dist/RefSubject/RefHashMap.js +317 -29
- package/dist/RefSubject/RefHashRing.d.ts +159 -15
- package/dist/RefSubject/RefHashRing.d.ts.map +1 -1
- package/dist/RefSubject/RefHashRing.js +145 -12
- package/dist/RefSubject/RefHashSet.d.ts +251 -22
- package/dist/RefSubject/RefHashSet.d.ts.map +1 -1
- package/dist/RefSubject/RefHashSet.js +238 -20
- package/dist/RefSubject/RefIterable.d.ts +358 -32
- package/dist/RefSubject/RefIterable.d.ts.map +1 -1
- package/dist/RefSubject/RefIterable.js +350 -30
- package/dist/RefSubject/RefOption.d.ts +157 -14
- package/dist/RefSubject/RefOption.d.ts.map +1 -1
- package/dist/RefSubject/RefOption.js +145 -13
- package/dist/RefSubject/RefRecord.d.ts +402 -64
- package/dist/RefSubject/RefRecord.d.ts.map +1 -1
- package/dist/RefSubject/RefRecord.js +364 -39
- package/dist/RefSubject/RefResult.d.ts +167 -35
- package/dist/RefSubject/RefResult.d.ts.map +1 -1
- package/dist/RefSubject/RefResult.js +133 -12
- package/dist/RefSubject/RefString.d.ts +205 -18
- package/dist/RefSubject/RefString.d.ts.map +1 -1
- package/dist/RefSubject/RefString.js +193 -17
- package/dist/RefSubject/RefStruct.d.ts +169 -14
- package/dist/RefSubject/RefStruct.d.ts.map +1 -1
- package/dist/RefSubject/RefStruct.js +157 -13
- package/dist/RefSubject/RefSubject.d.ts +1242 -43
- package/dist/RefSubject/RefSubject.d.ts.map +1 -1
- package/dist/RefSubject/RefSubject.js +1012 -86
- package/dist/RefSubject/RefTrie.d.ts +323 -37
- package/dist/RefSubject/RefTrie.d.ts.map +1 -1
- package/dist/RefSubject/RefTrie.js +311 -31
- package/dist/RefSubject/RefTuple.d.ts +127 -11
- package/dist/RefSubject/RefTuple.d.ts.map +1 -1
- package/dist/RefSubject/RefTuple.js +114 -9
- package/dist/RefSubject/index.d.ts +1 -0
- package/dist/RefSubject/index.d.ts.map +1 -1
- package/dist/RefSubject/index.js +1 -0
- package/dist/RefSubject.d.ts +2 -1
- package/dist/RefSubject.d.ts.map +1 -1
- package/dist/RefSubject.js +2 -1
- package/dist/RefTrie.d.ts +2 -0
- package/dist/RefTrie.d.ts.map +1 -0
- package/dist/RefTrie.js +1 -0
- package/dist/RefTuple.d.ts +2 -0
- package/dist/RefTuple.d.ts.map +1 -0
- package/dist/RefTuple.js +1 -0
- package/dist/Sink/Sink.d.ts +396 -23
- package/dist/Sink/Sink.d.ts.map +1 -1
- package/dist/Sink/Sink.js +55 -7
- package/dist/Sink/combinators.d.ts +789 -3
- package/dist/Sink/combinators.d.ts.map +1 -1
- package/dist/Sink/combinators.js +812 -7
- package/dist/Subject/Subject.d.ts +1022 -27
- package/dist/Subject/Subject.d.ts.map +1 -1
- package/dist/Subject/Subject.js +909 -43
- package/dist/Versioned/Versioned.d.ts +475 -25
- package/dist/Versioned/Versioned.d.ts.map +1 -1
- package/dist/Versioned/Versioned.js +298 -46
- package/dist/index.d.ts +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/package.json +125 -11
- package/dist/Fx/constructors/fromYieldable.d.ts +0 -12
- package/dist/Fx/constructors/fromYieldable.d.ts.map +0 -1
- package/dist/Fx/constructors/fromYieldable.js +0 -12
- package/src/Fx/Fx.ts +0 -164
- package/src/Fx/TypeId.ts +0 -25
- package/src/Fx/combinators/catch.ts +0 -165
- package/src/Fx/combinators/causes.ts +0 -23
- package/src/Fx/combinators/compact.ts +0 -15
- package/src/Fx/combinators/continueWith.ts +0 -78
- package/src/Fx/combinators/ensuring.ts +0 -23
- package/src/Fx/combinators/exhaustLatestMap.ts +0 -74
- package/src/Fx/combinators/exhaustLatestMapEffect.ts +0 -25
- package/src/Fx/combinators/exhaustMap.ts +0 -36
- package/src/Fx/combinators/exhaustMapEffect.ts +0 -23
- package/src/Fx/combinators/exit.ts +0 -15
- package/src/Fx/combinators/filter.ts +0 -22
- package/src/Fx/combinators/filterEffect.ts +0 -31
- package/src/Fx/combinators/filterMap.ts +0 -23
- package/src/Fx/combinators/filterMapEffect.ts +0 -32
- package/src/Fx/combinators/filterMapLoop.ts +0 -35
- package/src/Fx/combinators/filterMapLoopCause.ts +0 -36
- package/src/Fx/combinators/filterMapLoopCauseEffect.ts +0 -46
- package/src/Fx/combinators/filterMapLoopEffect.ts +0 -36
- package/src/Fx/combinators/flatMap.ts +0 -51
- package/src/Fx/combinators/flatMapConcurrently.ts +0 -36
- package/src/Fx/combinators/flatMapConcurrentlyEffect.ts +0 -26
- package/src/Fx/combinators/flatMapEffect.ts +0 -42
- package/src/Fx/combinators/flip.ts +0 -14
- package/src/Fx/combinators/gen.ts +0 -24
- package/src/Fx/combinators/genScoped.ts +0 -24
- package/src/Fx/combinators/index.ts +0 -51
- package/src/Fx/combinators/keyed.ts +0 -369
- package/src/Fx/combinators/loop.ts +0 -27
- package/src/Fx/combinators/loopCause.ts +0 -34
- package/src/Fx/combinators/loopCauseEffect.ts +0 -36
- package/src/Fx/combinators/loopEffect.ts +0 -34
- package/src/Fx/combinators/map.ts +0 -22
- package/src/Fx/combinators/mapEffect.ts +0 -32
- package/src/Fx/combinators/mergeAll.ts +0 -22
- package/src/Fx/combinators/mergeOrdered.ts +0 -123
- package/src/Fx/combinators/onError.ts +0 -40
- package/src/Fx/combinators/onExit.ts +0 -82
- package/src/Fx/combinators/onInterrupt.ts +0 -87
- package/src/Fx/combinators/provide.ts +0 -62
- package/src/Fx/combinators/skip.ts +0 -20
- package/src/Fx/combinators/skipRepeats.ts +0 -15
- package/src/Fx/combinators/skipRepeatsWith.ts +0 -40
- package/src/Fx/combinators/slice.ts +0 -32
- package/src/Fx/combinators/switchMap.ts +0 -55
- package/src/Fx/combinators/switchMapEffect.ts +0 -25
- package/src/Fx/combinators/take.ts +0 -17
- package/src/Fx/combinators/takeUntil.ts +0 -50
- package/src/Fx/combinators/tapEffect.ts +0 -39
- package/src/Fx/combinators/tuple.ts +0 -79
- package/src/Fx/combinators/unwrap.ts +0 -21
- package/src/Fx/combinators/unwrapScoped.ts +0 -26
- package/src/Fx/combinators/when.ts +0 -64
- package/src/Fx/combinators/withSpan.ts +0 -24
- package/src/Fx/constructors/at.ts +0 -23
- package/src/Fx/constructors/die.ts +0 -17
- package/src/Fx/constructors/empty.ts +0 -10
- package/src/Fx/constructors/fail.ts +0 -14
- package/src/Fx/constructors/failCause.ts +0 -14
- package/src/Fx/constructors/fn.ts +0 -245
- package/src/Fx/constructors/fromEffect.ts +0 -24
- package/src/Fx/constructors/fromFailures.ts +0 -19
- package/src/Fx/constructors/fromIterable.ts +0 -15
- package/src/Fx/constructors/fromSchedule.ts +0 -18
- package/src/Fx/constructors/fromYieldable.ts +0 -17
- package/src/Fx/constructors/index.ts +0 -15
- package/src/Fx/constructors/interrupt.ts +0 -13
- package/src/Fx/constructors/make.ts +0 -103
- package/src/Fx/constructors/periodic.ts +0 -15
- package/src/Fx/constructors/succeed.ts +0 -37
- package/src/Fx/constructors/suspend.ts +0 -6
- package/src/Fx/index.ts +0 -6
- package/src/Fx/internal/DeferredRef.ts +0 -87
- package/src/Fx/internal/UnionToTuple.ts +0 -12
- package/src/Fx/internal/diff.ts +0 -191
- package/src/Fx/internal/equivalence.ts +0 -12
- package/src/Fx/internal/multicast.ts +0 -51
- package/src/Fx/internal/ring-buffer.ts +0 -60
- package/src/Fx/internal/scope.ts +0 -58
- package/src/Fx/internal/yieldable.ts +0 -31
- package/src/Fx/run/collect.ts +0 -79
- package/src/Fx/run/first.ts +0 -20
- package/src/Fx/run/fork.ts +0 -40
- package/src/Fx/run/index.ts +0 -5
- package/src/Fx/run/observe.ts +0 -114
- package/src/Fx/run/runPromise.ts +0 -32
- package/src/Fx/stream.ts +0 -42
- package/src/Fx.catch.test.ts +0 -61
- package/src/Fx.fn.test.ts +0 -51
- package/src/Fx.lifecycle.test.ts +0 -80
- package/src/Fx.test.ts +0 -71
- package/src/Fx.ts +0 -1
- package/src/Push/Push.ts +0 -903
- package/src/Push/index.ts +0 -1
- package/src/Push.test.ts +0 -26
- package/src/Push.ts +0 -1
- package/src/RefSubject/RefArray.ts +0 -512
- package/src/RefSubject/RefBigDecimal.test.ts +0 -56
- package/src/RefSubject/RefBigDecimal.ts +0 -295
- package/src/RefSubject/RefBigInt.test.ts +0 -56
- package/src/RefSubject/RefBigInt.ts +0 -189
- package/src/RefSubject/RefBoolean.test.ts +0 -57
- package/src/RefSubject/RefBoolean.ts +0 -185
- package/src/RefSubject/RefCause.test.ts +0 -53
- package/src/RefSubject/RefCause.ts +0 -146
- package/src/RefSubject/RefChunk.ts +0 -510
- package/src/RefSubject/RefDateTime.test.ts +0 -43
- package/src/RefSubject/RefDateTime.ts +0 -264
- package/src/RefSubject/RefDuration.test.ts +0 -49
- package/src/RefSubject/RefDuration.ts +0 -188
- package/src/RefSubject/RefGraph.ts +0 -650
- package/src/RefSubject/RefHashMap.ts +0 -465
- package/src/RefSubject/RefHashRing.ts +0 -262
- package/src/RefSubject/RefHashSet.ts +0 -308
- package/src/RefSubject/RefIterable.ts +0 -445
- package/src/RefSubject/RefOption.test.ts +0 -67
- package/src/RefSubject/RefOption.ts +0 -193
- package/src/RefSubject/RefRecord.ts +0 -612
- package/src/RefSubject/RefResult.test.ts +0 -63
- package/src/RefSubject/RefResult.ts +0 -209
- package/src/RefSubject/RefString.test.ts +0 -61
- package/src/RefSubject/RefString.ts +0 -256
- package/src/RefSubject/RefStruct.test.ts +0 -60
- package/src/RefSubject/RefStruct.ts +0 -253
- package/src/RefSubject/RefSubject.ts +0 -2545
- package/src/RefSubject/RefTrie.ts +0 -356
- package/src/RefSubject/RefTuple.test.ts +0 -60
- package/src/RefSubject/RefTuple.ts +0 -231
- package/src/RefSubject/index.ts +0 -21
- package/src/RefSubject.test.ts +0 -65
- package/src/RefSubject.ts +0 -1
- package/src/Sink/Sink.ts +0 -159
- package/src/Sink/combinators.ts +0 -993
- package/src/Sink/index.ts +0 -2
- package/src/Sink.ts +0 -1
- package/src/Subject/Subject.ts +0 -441
- package/src/Subject/index.ts +0 -1
- package/src/Subject.test.ts +0 -47
- package/src/Subject.ts +0 -1
- package/src/Versioned/Versioned.ts +0 -521
- package/src/Versioned/index.ts +0 -1
- package/src/Versioned.test.ts +0 -23
- package/src/Versioned.ts +0 -1
- package/src/index.ts +0 -7
- package/tsconfig.json +0 -6
|
@@ -6,27 +6,134 @@ import type { Equivalence } from "effect/Equivalence";
|
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
import * as Scope from "effect/Scope";
|
|
9
|
-
import * as
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
10
|
import * as Stream from "effect/Stream";
|
|
11
11
|
import type { Error as FxError, Fx } from "../Fx/index.js";
|
|
12
12
|
import type { UnionToTuple } from "../Fx/internal/UnionToTuple.js";
|
|
13
13
|
import * as Subject from "../Subject/Subject.js";
|
|
14
14
|
import * as Versioned from "../Versioned/Versioned.js";
|
|
15
|
+
/**
|
|
16
|
+
* Runtime symbol identifying writable RefSubject values.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* ## Why
|
|
20
|
+
*
|
|
21
|
+
* Provides stable runtime identity for RefSubject values without relying on classes or a renderer.
|
|
22
|
+
*
|
|
23
|
+
* ## Ownership and lifetime
|
|
24
|
+
*
|
|
25
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
26
|
+
* source errors, services, and lifetime.
|
|
27
|
+
*
|
|
28
|
+
* @since 1.18.0
|
|
29
|
+
* @category Type identity
|
|
30
|
+
*/
|
|
15
31
|
export declare const RefSubjectTypeId: unique symbol;
|
|
32
|
+
/**
|
|
33
|
+
* Describes the ref subject type id type.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* ## Why
|
|
37
|
+
*
|
|
38
|
+
* Provides stable runtime identity for RefSubject values without relying on classes or a renderer.
|
|
39
|
+
*
|
|
40
|
+
* ## Ownership and lifetime
|
|
41
|
+
*
|
|
42
|
+
* RefSubjectTypeId is a contract and performs no acquisition. Implementations retain the errors,
|
|
43
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
44
|
+
*
|
|
45
|
+
* @since 1.18.0
|
|
46
|
+
* @category Type utilities
|
|
47
|
+
*/
|
|
16
48
|
export type RefSubjectTypeId = typeof RefSubjectTypeId;
|
|
49
|
+
/**
|
|
50
|
+
* Runtime symbol identifying read-only Computed values.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* ## Why
|
|
54
|
+
*
|
|
55
|
+
* Provides stable runtime identity for Computed values without relying on classes or a renderer.
|
|
56
|
+
*
|
|
57
|
+
* ## Ownership and lifetime
|
|
58
|
+
*
|
|
59
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
60
|
+
* source errors, services, and lifetime.
|
|
61
|
+
*
|
|
62
|
+
* @since 1.18.0
|
|
63
|
+
* @category Type identity
|
|
64
|
+
*/
|
|
17
65
|
export declare const ComputedTypeId: unique symbol;
|
|
66
|
+
/**
|
|
67
|
+
* Describes the computed type id type.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* ## Why
|
|
71
|
+
*
|
|
72
|
+
* Provides stable runtime identity for Computed values without relying on classes or a renderer.
|
|
73
|
+
*
|
|
74
|
+
* ## Ownership and lifetime
|
|
75
|
+
*
|
|
76
|
+
* ComputedTypeId is a contract and performs no acquisition. Implementations retain the errors,
|
|
77
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
78
|
+
*
|
|
79
|
+
* @since 1.18.0
|
|
80
|
+
* @category Type utilities
|
|
81
|
+
*/
|
|
18
82
|
export type ComputedTypeId = typeof ComputedTypeId;
|
|
83
|
+
/**
|
|
84
|
+
* Runtime symbol identifying conditionally available Filtered values.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* ## Why
|
|
88
|
+
*
|
|
89
|
+
* Provides stable runtime identity for Filtered values without relying on classes or a renderer.
|
|
90
|
+
*
|
|
91
|
+
* ## Ownership and lifetime
|
|
92
|
+
*
|
|
93
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
94
|
+
* source errors, services, and lifetime.
|
|
95
|
+
*
|
|
96
|
+
* @since 1.18.0
|
|
97
|
+
* @category Type identity
|
|
98
|
+
*/
|
|
19
99
|
export declare const FilteredTypeId: unique symbol;
|
|
100
|
+
/**
|
|
101
|
+
* Describes the filtered type id type.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* ## Why
|
|
105
|
+
*
|
|
106
|
+
* Provides stable runtime identity for Filtered values without relying on classes or a renderer.
|
|
107
|
+
*
|
|
108
|
+
* ## Ownership and lifetime
|
|
109
|
+
*
|
|
110
|
+
* FilteredTypeId is a contract and performs no acquisition. Implementations retain the errors,
|
|
111
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
112
|
+
*
|
|
113
|
+
* @since 1.18.0
|
|
114
|
+
* @category Type utilities
|
|
115
|
+
*/
|
|
20
116
|
export type FilteredTypeId = typeof FilteredTypeId;
|
|
21
117
|
/**
|
|
22
118
|
* A `Computed` is a read-only view of a value that can change over time.
|
|
23
119
|
* It is an `Fx` that emits the current value and subsequent updates.
|
|
24
120
|
* It is also an `Effect` that samples the current value.
|
|
25
121
|
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* ## Why
|
|
124
|
+
*
|
|
125
|
+
* Represents derived state as both an Effectful current read and an Fx of subsequent versions,
|
|
126
|
+
* without granting write access.
|
|
127
|
+
*
|
|
128
|
+
* ## Ownership and lifetime
|
|
129
|
+
*
|
|
130
|
+
* Computed is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
131
|
+
* interruption, and Scope requirements expressed by its members.
|
|
132
|
+
*
|
|
26
133
|
* @example
|
|
27
134
|
* ```ts
|
|
28
135
|
* import { Effect } from "effect"
|
|
29
|
-
* import
|
|
136
|
+
* import { RefSubject } from "@typed/fx"
|
|
30
137
|
* import { Fx } from "@typed/fx"
|
|
31
138
|
*
|
|
32
139
|
* // Create a RefSubject and derive a Computed from it
|
|
@@ -50,22 +157,83 @@ export type FilteredTypeId = typeof FilteredTypeId;
|
|
|
50
157
|
* ```
|
|
51
158
|
*
|
|
52
159
|
* @since 1.0.0
|
|
53
|
-
* @category
|
|
160
|
+
* @category Read-only state
|
|
54
161
|
*/
|
|
55
162
|
export interface Computed<out A, out E = never, out R = never> extends Versioned.Versioned<R, E, A, E, R | Scope.Scope, A, E, R> {
|
|
163
|
+
/**
|
|
164
|
+
* Carries the runtime marker recognized by `isComputed`.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* ## Why
|
|
168
|
+
*
|
|
169
|
+
* Marks the value as Computed for runtime guards and composition without granting writable
|
|
170
|
+
* RefSubject operations.
|
|
171
|
+
*
|
|
172
|
+
* ## Ownership and lifetime
|
|
173
|
+
*
|
|
174
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
175
|
+
* source errors, services, and lifetime.
|
|
176
|
+
*
|
|
177
|
+
* @since 1.18.0
|
|
178
|
+
* @category State protocol
|
|
179
|
+
*/
|
|
56
180
|
readonly [ComputedTypeId]: ComputedTypeId;
|
|
57
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Type utilities for read-only Computed state.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* ## Why
|
|
187
|
+
*
|
|
188
|
+
* Represents derived state as both an Effectful current read and an Fx of subsequent versions,
|
|
189
|
+
* without granting write access.
|
|
190
|
+
*
|
|
191
|
+
* ## Ownership and lifetime
|
|
192
|
+
*
|
|
193
|
+
* A namespace declaration performs no read or acquisition. The Computed values described by its
|
|
194
|
+
* members retain their own errors, services, and Scope-owned observation lifetimes.
|
|
195
|
+
*
|
|
196
|
+
* @since 1.18.0
|
|
197
|
+
* @category Read-only state
|
|
198
|
+
*/
|
|
58
199
|
export declare namespace Computed {
|
|
200
|
+
/**
|
|
201
|
+
* Describes the any type.
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* ## Why
|
|
205
|
+
*
|
|
206
|
+
* The result remains a lazy view rather than a duplicated mutable value.
|
|
207
|
+
*
|
|
208
|
+
* ## Ownership and lifetime
|
|
209
|
+
*
|
|
210
|
+
* Any is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
211
|
+
* interruption, and Scope requirements expressed by its members.
|
|
212
|
+
*
|
|
213
|
+
* @since 1.18.0
|
|
214
|
+
* @category Type utilities
|
|
215
|
+
*/
|
|
59
216
|
type Any = Computed<any, any, any> | Computed<never, any, any> | Computed<any, never, any> | Computed<never, never, any>;
|
|
60
217
|
}
|
|
61
218
|
/**
|
|
62
219
|
* A `Filtered` is a `Computed` that may not always have a value.
|
|
63
220
|
* It is essentially a `Computed<Option<A>>` with helper methods.
|
|
64
221
|
*
|
|
222
|
+
* @remarks
|
|
223
|
+
* ## Why
|
|
224
|
+
*
|
|
225
|
+
* Represents a derived value that may be absent now and become available on a later push,
|
|
226
|
+
* preserving absence in the state contract.
|
|
227
|
+
*
|
|
228
|
+
* ## Ownership and lifetime
|
|
229
|
+
*
|
|
230
|
+
* Filtered is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
231
|
+
* interruption, and Scope requirements expressed by its members.
|
|
232
|
+
*
|
|
65
233
|
* @example
|
|
66
234
|
* ```ts
|
|
67
235
|
* import { Effect, Option } from "effect"
|
|
68
|
-
* import
|
|
236
|
+
* import { RefSubject } from "@typed/fx"
|
|
69
237
|
*
|
|
70
238
|
* // Create a RefSubject and filter it
|
|
71
239
|
* const program = Effect.gen(function* () {
|
|
@@ -89,9 +257,26 @@ export declare namespace Computed {
|
|
|
89
257
|
* ```
|
|
90
258
|
*
|
|
91
259
|
* @since 1.0.0
|
|
92
|
-
* @category
|
|
260
|
+
* @category Read-only state
|
|
93
261
|
*/
|
|
94
262
|
export interface Filtered<out A, out E = never, out R = never> extends Versioned.Versioned<R, E, A, E, R | Scope.Scope, A, E | Cause.NoSuchElementError, R> {
|
|
263
|
+
/**
|
|
264
|
+
* Carries the runtime marker distinguishing conditional Filtered state from Computed state.
|
|
265
|
+
*
|
|
266
|
+
* @remarks
|
|
267
|
+
* ## Why
|
|
268
|
+
*
|
|
269
|
+
* Marks the value as Filtered for runtime guards and composition without changing its data or
|
|
270
|
+
* error channels.
|
|
271
|
+
*
|
|
272
|
+
* ## Ownership and lifetime
|
|
273
|
+
*
|
|
274
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
275
|
+
* source errors, services, and lifetime.
|
|
276
|
+
*
|
|
277
|
+
* @since 1.18.0
|
|
278
|
+
* @category State protocol
|
|
279
|
+
*/
|
|
95
280
|
readonly [FilteredTypeId]: FilteredTypeId;
|
|
96
281
|
/**
|
|
97
282
|
* Converts the Filtered back to a Computed of Option.
|
|
@@ -113,34 +298,151 @@ export interface Filtered<out A, out E = never, out R = never> extends Versioned
|
|
|
113
298
|
* console.log(Option.isNone(option)) // true (no number > 5)
|
|
114
299
|
* })
|
|
115
300
|
* ```
|
|
301
|
+
* @category Optional queries
|
|
302
|
+
* @since 1.18.0
|
|
303
|
+
* @remarks
|
|
304
|
+
* ## Why
|
|
305
|
+
*
|
|
306
|
+
* Converts the Filtered back to a Computed of Option. The result remains a lazy view rather than a
|
|
307
|
+
* duplicated mutable value.
|
|
308
|
+
*
|
|
309
|
+
* ## Ownership and lifetime
|
|
310
|
+
*
|
|
311
|
+
* The as computed view retains no independent state. Effectful reads sample the source once;
|
|
312
|
+
* Fx observation follows later pushes and the observing Scope finalizes it.
|
|
313
|
+
*
|
|
116
314
|
*/
|
|
117
315
|
asComputed(): Computed<Option.Option<A>, E, R>;
|
|
118
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Type utilities for conditionally available Filtered state.
|
|
319
|
+
*
|
|
320
|
+
* @remarks
|
|
321
|
+
* ## Why
|
|
322
|
+
*
|
|
323
|
+
* Represents a derived value that may be absent now and become available on a later push,
|
|
324
|
+
* preserving absence in the state contract.
|
|
325
|
+
*
|
|
326
|
+
* ## Ownership and lifetime
|
|
327
|
+
*
|
|
328
|
+
* A namespace declaration performs no read or acquisition. Individual Filtered values fail
|
|
329
|
+
* current reads with `NoSuchElementError` while absent; their observing Scope owns Fx cleanup.
|
|
330
|
+
*
|
|
331
|
+
* @since 1.18.0
|
|
332
|
+
* @category Read-only state
|
|
333
|
+
*/
|
|
119
334
|
export declare namespace Filtered {
|
|
335
|
+
/**
|
|
336
|
+
* Describes the any type.
|
|
337
|
+
*
|
|
338
|
+
* @remarks
|
|
339
|
+
* ## Why
|
|
340
|
+
*
|
|
341
|
+
* Gives generic utilities one structural supertype for Filtered values without erasing the
|
|
342
|
+
* concrete channels of values passed through those utilities.
|
|
343
|
+
*
|
|
344
|
+
* ## Ownership and lifetime
|
|
345
|
+
*
|
|
346
|
+
* Any is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
347
|
+
* interruption, and Scope requirements expressed by its members.
|
|
348
|
+
*
|
|
349
|
+
* @since 1.18.0
|
|
350
|
+
* @category Type utilities
|
|
351
|
+
*/
|
|
120
352
|
type Any = Filtered<any, any, any> | Filtered<never, any, any> | Filtered<any, never, any> | Filtered<never, never, any>;
|
|
121
353
|
}
|
|
122
354
|
/**
|
|
123
355
|
* Interface for basic RefSubject operations: get, set, delete.
|
|
356
|
+
* @remarks
|
|
357
|
+
* ## Why
|
|
358
|
+
*
|
|
359
|
+
* Interface for basic RefSubject operations: get, set, delete.
|
|
360
|
+
*
|
|
361
|
+
* ## Ownership and lifetime
|
|
362
|
+
*
|
|
363
|
+
* GetSetDelete is a contract and performs no acquisition. Implementations retain the errors,
|
|
364
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
365
|
+
*
|
|
124
366
|
* @since 1.0.0
|
|
125
|
-
* @category
|
|
367
|
+
* @category Transactions
|
|
126
368
|
*/
|
|
127
369
|
export interface GetSetDelete<A, E = never, R = never> {
|
|
370
|
+
/**
|
|
371
|
+
* Reads the value visible to the current transaction.
|
|
372
|
+
*
|
|
373
|
+
* @remarks
|
|
374
|
+
* ## Why
|
|
375
|
+
*
|
|
376
|
+
* Reads the value visible inside the current transaction without publishing a change.
|
|
377
|
+
*
|
|
378
|
+
* ## Ownership and lifetime
|
|
379
|
+
*
|
|
380
|
+
* Running `get` performs no mutation or acquisition. It can fail with `E` and requires `R`; when
|
|
381
|
+
* used by `updates`, it observes that transaction's buffered value.
|
|
382
|
+
*
|
|
383
|
+
* @since 1.18.0
|
|
384
|
+
* @category Current reads
|
|
385
|
+
*/
|
|
128
386
|
readonly get: Effect.Effect<A, E, R>;
|
|
387
|
+
/**
|
|
388
|
+
* Replaces the value inside the current transaction.
|
|
389
|
+
*
|
|
390
|
+
* @remarks
|
|
391
|
+
* ## Why
|
|
392
|
+
*
|
|
393
|
+
* The transition is serialized at the RefSubject rather than coordinated by callers or UI
|
|
394
|
+
* components.
|
|
395
|
+
*
|
|
396
|
+
* ## Ownership and lifetime
|
|
397
|
+
*
|
|
398
|
+
* Running set performs one serialized subject transition and returns the committed value. It
|
|
399
|
+
* acquires no resource and preserves source failures and services.
|
|
400
|
+
*
|
|
401
|
+
* @since 1.18.0
|
|
402
|
+
* @category State updates
|
|
403
|
+
*/
|
|
129
404
|
readonly set: (a: A) => Effect.Effect<A, E, R>;
|
|
405
|
+
/**
|
|
406
|
+
* Removes and returns the value visible to the current transaction.
|
|
407
|
+
*
|
|
408
|
+
* @remarks
|
|
409
|
+
* ## Why
|
|
410
|
+
*
|
|
411
|
+
* Removes the value from the current transaction and returns the previous value as `Some`, or
|
|
412
|
+
* `None` when no value was present.
|
|
413
|
+
*
|
|
414
|
+
* ## Ownership and lifetime
|
|
415
|
+
*
|
|
416
|
+
* Running delete performs one serialized subject transition and returns the committed value.
|
|
417
|
+
* It acquires no resource and preserves source failures and services.
|
|
418
|
+
*
|
|
419
|
+
* @since 1.18.0
|
|
420
|
+
* @category State updates
|
|
421
|
+
*/
|
|
130
422
|
readonly delete: Effect.Effect<Option.Option<A>, E, R>;
|
|
131
423
|
}
|
|
132
424
|
/**
|
|
133
425
|
* A `RefSubject` is a mutable reference that can be observed as an Fx.
|
|
134
426
|
* It combines the capabilities of a `Ref` (get/set/update) with a `Subject` (subscribe).
|
|
135
427
|
*
|
|
428
|
+
* @remarks
|
|
429
|
+
* ## Why
|
|
430
|
+
*
|
|
431
|
+
* Unifies synchronized mutable state, Effectful current reads, and Fx pushes so the same state can
|
|
432
|
+
* be tested and consumed without a renderer.
|
|
433
|
+
*
|
|
434
|
+
* ## Ownership and lifetime
|
|
435
|
+
*
|
|
436
|
+
* RefSubject is a contract and performs no acquisition. Implementations retain the errors,
|
|
437
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
438
|
+
*
|
|
136
439
|
* @example
|
|
137
440
|
* ```ts
|
|
138
441
|
* import { Effect } from "effect"
|
|
139
|
-
* import
|
|
140
|
-
* import { Fx } from "@typed/fx"
|
|
442
|
+
* import { Fx, RefSubject } from "@typed/fx"
|
|
141
443
|
*
|
|
142
444
|
* // Create a RefSubject with an initial value
|
|
143
|
-
* const program = Effect.gen(function* () {
|
|
445
|
+
* const program = Effect.scoped(Effect.gen(function* () {
|
|
144
446
|
* const count = yield* RefSubject.make(0)
|
|
145
447
|
*
|
|
146
448
|
* // Get the current value
|
|
@@ -153,21 +455,38 @@ export interface GetSetDelete<A, E = never, R = never> {
|
|
|
153
455
|
* console.log(updated) // 5
|
|
154
456
|
*
|
|
155
457
|
* // Use as an Fx to observe changes
|
|
156
|
-
* yield* Fx.observe(
|
|
458
|
+
* yield* Effect.forkScoped(Fx.observe(
|
|
157
459
|
* count,
|
|
158
460
|
* (value) => Effect.sync(() => console.log("Count changed:", value))
|
|
159
|
-
* )
|
|
461
|
+
* ))
|
|
160
462
|
*
|
|
161
463
|
* // Increment
|
|
162
464
|
* yield* RefSubject.increment(count)
|
|
163
465
|
* // Output: "Count changed: 6"
|
|
164
|
-
* })
|
|
466
|
+
* }))
|
|
165
467
|
* ```
|
|
166
468
|
*
|
|
167
469
|
* @since 1.0.0
|
|
168
|
-
* @category
|
|
470
|
+
* @category Writable state
|
|
169
471
|
*/
|
|
170
472
|
export interface RefSubject<A, E = never, R = never> extends Computed<A, E, R>, Subject.Subject<A, E, R> {
|
|
473
|
+
/**
|
|
474
|
+
* Carries the runtime marker recognized by `isRefSubject`.
|
|
475
|
+
*
|
|
476
|
+
* @remarks
|
|
477
|
+
* ## Why
|
|
478
|
+
*
|
|
479
|
+
* Marks the value as a writable RefSubject for runtime guards while retaining its Computed and
|
|
480
|
+
* Subject capabilities.
|
|
481
|
+
*
|
|
482
|
+
* ## Ownership and lifetime
|
|
483
|
+
*
|
|
484
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
485
|
+
* source errors, services, and lifetime.
|
|
486
|
+
*
|
|
487
|
+
* @since 1.18.0
|
|
488
|
+
* @category State protocol
|
|
489
|
+
*/
|
|
171
490
|
readonly [RefSubjectTypeId]: RefSubjectTypeId;
|
|
172
491
|
/**
|
|
173
492
|
* Runs an effect that can modify the RefSubject transactionally.
|
|
@@ -194,6 +513,20 @@ export interface RefSubject<A, E = never, R = never> extends Computed<A, E, R>,
|
|
|
194
513
|
* )
|
|
195
514
|
* })
|
|
196
515
|
* ```
|
|
516
|
+
* @category Transactions
|
|
517
|
+
* @since 1.18.0
|
|
518
|
+
* @remarks
|
|
519
|
+
* ## Why
|
|
520
|
+
*
|
|
521
|
+
* Runs an effect that can modify the RefSubject transactionally. All operations within the
|
|
522
|
+
* transaction are atomic and serialized. The transition is serialized at the RefSubject rather
|
|
523
|
+
* than coordinated by callers or UI components.
|
|
524
|
+
*
|
|
525
|
+
* ## Ownership and lifetime
|
|
526
|
+
*
|
|
527
|
+
* Running updates performs one serialized subject transition and returns the committed value.
|
|
528
|
+
* It acquires no resource and preserves source failures and services.
|
|
529
|
+
*
|
|
197
530
|
*/
|
|
198
531
|
readonly updates: <B, E2, R2>(f: (ref: GetSetDelete<A, E, R>) => Effect.Effect<B, E2, R2>) => Effect.Effect<B, E | E2, R | R2>;
|
|
199
532
|
/**
|
|
@@ -211,33 +544,371 @@ export interface RefSubject<A, E = never, R = never> extends Computed<A, E, R>,
|
|
|
211
544
|
* yield* ref.interrupt
|
|
212
545
|
* })
|
|
213
546
|
* ```
|
|
547
|
+
* @category Lifetime
|
|
548
|
+
* @since 1.18.0
|
|
549
|
+
* @remarks
|
|
550
|
+
* ## Why
|
|
551
|
+
*
|
|
552
|
+
* Interrupts the RefSubject, stopping all subscriptions and cleaning up resources.
|
|
553
|
+
*
|
|
554
|
+
* ## Ownership and lifetime
|
|
555
|
+
*
|
|
556
|
+
* Running this Effect returns `void`: it resets pending initialization, closes the RefSubject's
|
|
557
|
+
* private Scope, interrupts its initializer fiber, and interrupts its Subject. It cannot fail;
|
|
558
|
+
* `R` supplies services captured by the RefSubject's internal lifetime.
|
|
559
|
+
*
|
|
214
560
|
*/
|
|
215
561
|
readonly interrupt: Effect.Effect<void, never, R>;
|
|
216
562
|
}
|
|
563
|
+
/**
|
|
564
|
+
* Type utilities and service contracts for RefSubject values.
|
|
565
|
+
*
|
|
566
|
+
* @remarks
|
|
567
|
+
* ## Why
|
|
568
|
+
*
|
|
569
|
+
* Unifies synchronized mutable state, Effectful current reads, and Fx pushes so the same state can
|
|
570
|
+
* be tested and consumed without a renderer.
|
|
571
|
+
*
|
|
572
|
+
* ## Ownership and lifetime
|
|
573
|
+
*
|
|
574
|
+
* The namespace itself cannot run, read, or commit state. It groups structural helper types and
|
|
575
|
+
* the Context-backed service facade; concrete RefSubject values own their own Scope and serialized
|
|
576
|
+
* update boundary.
|
|
577
|
+
*
|
|
578
|
+
* @since 1.18.0
|
|
579
|
+
* @category Writable state
|
|
580
|
+
*/
|
|
217
581
|
export declare namespace RefSubject {
|
|
582
|
+
/**
|
|
583
|
+
* Describes the any type.
|
|
584
|
+
*
|
|
585
|
+
* @remarks
|
|
586
|
+
* ## Why
|
|
587
|
+
*
|
|
588
|
+
* Gives generic utilities one structural supertype for writable RefSubject values while leaving
|
|
589
|
+
* concrete value, error, and service channels available to conditional types.
|
|
590
|
+
*
|
|
591
|
+
* ## Ownership and lifetime
|
|
592
|
+
*
|
|
593
|
+
* Any is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
594
|
+
* interruption, and Scope requirements expressed by its members.
|
|
595
|
+
*
|
|
596
|
+
* @since 1.18.0
|
|
597
|
+
* @category Type utilities
|
|
598
|
+
*/
|
|
218
599
|
type Any = RefSubject<any, any, any> | RefSubject<any, any> | RefSubject<any, never, any> | RefSubject<any>;
|
|
600
|
+
/**
|
|
601
|
+
* Defines the service state contract.
|
|
602
|
+
*
|
|
603
|
+
* @remarks
|
|
604
|
+
* ## Why
|
|
605
|
+
*
|
|
606
|
+
* Describes the class-like facade returned by `RefSubject.Service`: it is a Context tag whose
|
|
607
|
+
* static members also implement current reads, Fx observation, and serialized writes.
|
|
608
|
+
*
|
|
609
|
+
* ## Ownership and lifetime
|
|
610
|
+
*
|
|
611
|
+
* The contract itself acquires nothing. A matching Layer owns the underlying RefSubject; using
|
|
612
|
+
* the facade requires `Self`, exposes the underlying `E` on reads and pushes, and forwards Scope
|
|
613
|
+
* ownership to that installed subject.
|
|
614
|
+
*
|
|
615
|
+
* @since 1.18.0
|
|
616
|
+
* @category Services
|
|
617
|
+
*/
|
|
219
618
|
interface Service<Self, Id extends string, A, E> extends RefSubject<A, E, Self> {
|
|
619
|
+
/**
|
|
620
|
+
* Exposes id on the ref subject contract.
|
|
621
|
+
*
|
|
622
|
+
* @remarks
|
|
623
|
+
* ## Why
|
|
624
|
+
*
|
|
625
|
+
* Preserves the literal Context identifier used to construct and diagnose the service tag.
|
|
626
|
+
*
|
|
627
|
+
* ## Ownership and lifetime
|
|
628
|
+
*
|
|
629
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
630
|
+
* source errors, services, and lifetime.
|
|
631
|
+
*
|
|
632
|
+
* @since 1.18.0
|
|
633
|
+
* @category Services
|
|
634
|
+
*/
|
|
220
635
|
readonly id: Id;
|
|
221
|
-
|
|
636
|
+
/**
|
|
637
|
+
* Exposes service on the ref subject contract.
|
|
638
|
+
*
|
|
639
|
+
* @remarks
|
|
640
|
+
* ## Why
|
|
641
|
+
*
|
|
642
|
+
* Exposes the exact Effect Context tag used by `layer`, `make`, and every static operation on
|
|
643
|
+
* the facade, so custom Layers can install an existing RefSubject without another wrapper.
|
|
644
|
+
*
|
|
645
|
+
* ## Ownership and lifetime
|
|
646
|
+
*
|
|
647
|
+
* The tag is pure metadata and owns no state. The Layer that provides it owns the installed
|
|
648
|
+
* RefSubject and its scoped initializer; operations retrieving it require `Self`.
|
|
649
|
+
*
|
|
650
|
+
* @since 1.18.0
|
|
651
|
+
* @category Services
|
|
652
|
+
*/
|
|
653
|
+
readonly service: Context.Service<Self, RefSubject<A, E>>;
|
|
654
|
+
/**
|
|
655
|
+
* Exposes make on the ref subject contract.
|
|
656
|
+
*
|
|
657
|
+
* @remarks
|
|
658
|
+
* ## Why
|
|
659
|
+
*
|
|
660
|
+
* Accepts values, Effects, Streams, and Fx through one renderer-independent state constructor
|
|
661
|
+
* while retaining their typed failures and services.
|
|
662
|
+
*
|
|
663
|
+
* ## Ownership and lifetime
|
|
664
|
+
*
|
|
665
|
+
* The creation Effect requires Scope. It owns initializer acquisition, live source subscriptions,
|
|
666
|
+
* and cleanup; source failures and services stay on reads and pushes.
|
|
667
|
+
*
|
|
668
|
+
* @since 1.18.0
|
|
669
|
+
* @category Constructors
|
|
670
|
+
*/
|
|
222
671
|
readonly make: <R = never>(value: A | Effect.Effect<A, E, R> | Fx<A, E, R>, options?: RefSubjectOptions<A> & {
|
|
223
672
|
readonly skip?: number;
|
|
224
673
|
readonly take?: number;
|
|
225
674
|
}) => Layer.Layer<Self, never, Exclude<R, Scope.Scope>>;
|
|
675
|
+
/**
|
|
676
|
+
* Exposes layer on the ref subject contract.
|
|
677
|
+
*
|
|
678
|
+
* @remarks
|
|
679
|
+
* ## Why
|
|
680
|
+
*
|
|
681
|
+
* Converts a scoped Effect that produces a RefSubject into the exact Layer required by the
|
|
682
|
+
* facade, preserving construction failures and non-Scope requirements.
|
|
683
|
+
*
|
|
684
|
+
* ## Ownership and lifetime
|
|
685
|
+
*
|
|
686
|
+
* Layer acquisition runs `make` once per Layer instance. Its Scope owns the installed subject;
|
|
687
|
+
* `E2` is a Layer-construction failure, while the subject's `E` remains on later state access.
|
|
688
|
+
*
|
|
689
|
+
* @since 1.18.0
|
|
690
|
+
* @category Service layers
|
|
691
|
+
*/
|
|
226
692
|
readonly layer: <E2, R2>(make: Effect.Effect<RefSubject<A, E>, E2, R2 | Scope.Scope>) => Layer.Layer<Self, E2, Exclude<R2, Scope.Scope>>;
|
|
227
693
|
}
|
|
694
|
+
/**
|
|
695
|
+
* Defines the class state contract.
|
|
696
|
+
*
|
|
697
|
+
* @remarks
|
|
698
|
+
* ## Why
|
|
699
|
+
*
|
|
700
|
+
* Adds the construct signature used by class-extension syntax to the RefSubject service facade.
|
|
701
|
+
*
|
|
702
|
+
* ## Ownership and lifetime
|
|
703
|
+
*
|
|
704
|
+
* Class is a contract and performs no acquisition. Implementations retain the errors,
|
|
705
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
706
|
+
*
|
|
707
|
+
* @since 1.18.0
|
|
708
|
+
* @category Services
|
|
709
|
+
*/
|
|
228
710
|
interface Class<Self, Id extends string, A, E> extends RefSubject.Service<Self, Id, A, E> {
|
|
711
|
+
/**
|
|
712
|
+
* Construct signature used by the generated RefSubject service class.
|
|
713
|
+
*
|
|
714
|
+
* @remarks
|
|
715
|
+
* ## Why
|
|
716
|
+
*
|
|
717
|
+
* Makes `class State extends RefSubject.Service(...)(id) {}` type-check while returning the
|
|
718
|
+
* static facade rather than allocating a second state object.
|
|
719
|
+
*
|
|
720
|
+
* ## Ownership and lifetime
|
|
721
|
+
*
|
|
722
|
+
* Constructing the generated class returns its static service facade; it does not allocate or
|
|
723
|
+
* acquire a RefSubject. The matching Layer owns the installed state and its Scope.
|
|
724
|
+
*
|
|
725
|
+
* @since 1.18.0
|
|
726
|
+
* @category Type utilities
|
|
727
|
+
*/
|
|
229
728
|
new (): RefSubject.Service<Self, Id, A, E>;
|
|
230
729
|
}
|
|
231
730
|
}
|
|
232
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Selects whether a computed Fx observes only its current value or also follows later pushes.
|
|
733
|
+
*
|
|
734
|
+
* @remarks
|
|
735
|
+
* ## Why
|
|
736
|
+
*
|
|
737
|
+
* `"multiple"` (the default) emits the current value and then follows distinct source pushes.
|
|
738
|
+
* `"one"` emits only the current value. Hydration temporarily uses `"one"` when it must resolve a
|
|
739
|
+
* single server value without leaving a live observation running.
|
|
740
|
+
*
|
|
741
|
+
* ## Ownership and lifetime
|
|
742
|
+
*
|
|
743
|
+
* This is an Effect Context reference with a default value, not mutable global state. Supplying a
|
|
744
|
+
* value changes computed observation only in the provided Effect context; the observing Scope
|
|
745
|
+
* still owns any subscription created by `"multiple"`.
|
|
746
|
+
*
|
|
747
|
+
* @since 1.18.0
|
|
748
|
+
* @category Observation policy
|
|
749
|
+
*/
|
|
750
|
+
export declare const CurrentComputedBehavior: Context.Reference<"multiple" | "one">;
|
|
751
|
+
/**
|
|
752
|
+
* Builds a read-only Computed projection from a Versioned source.
|
|
753
|
+
*
|
|
754
|
+
* @remarks
|
|
755
|
+
* ## Why
|
|
756
|
+
*
|
|
757
|
+
* Applies the same Effectful projection to current reads and pushed versions, preserving all three
|
|
758
|
+
* Versioned channels without granting writes to the source.
|
|
759
|
+
*
|
|
760
|
+
* ## Ownership and lifetime
|
|
761
|
+
*
|
|
762
|
+
* Current reads cache the transformed input by source version within each Effect Context. The
|
|
763
|
+
* pushed channel uses `Subject.hold`: observers with the same Context object share one upstream
|
|
764
|
+
* session and its retained projection; distinct Context objects have separate sessions. The last
|
|
765
|
+
* observer ends its session and clears its held value. The observing Scope owns cleanup.
|
|
766
|
+
*
|
|
767
|
+
* @since 1.18.0
|
|
768
|
+
* @category Derived queries
|
|
769
|
+
*/
|
|
233
770
|
export declare function makeComputed<R0, E0, A, E, R, E2, R2, C, E3, R3>(input: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, f: (a: A) => Effect.Effect<C, E3, R3>): Computed<C, E0 | E | E2 | E3, R0 | R2 | R3 | Exclude<R, Scope.Scope>>;
|
|
771
|
+
/**
|
|
772
|
+
* Stateful scan over a `RefSubject` / `Computed`, producing a `Computed` of the accumulated state.
|
|
773
|
+
*
|
|
774
|
+
* Fx subscriptions follow `Fx.scan` semantics (emit `initial`, then fold each source value).
|
|
775
|
+
* Effect sampling accumulates across source versions via a private state ref (do not mix heavy
|
|
776
|
+
* subscribe + sample on the same scan if you need a single shared accumulator).
|
|
777
|
+
*
|
|
778
|
+
* @remarks
|
|
779
|
+
* ## Why
|
|
780
|
+
*
|
|
781
|
+
* Stateful scan over a `RefSubject` / `Computed`, producing a `Computed` of the accumulated state.
|
|
782
|
+
* Fx subscriptions follow `Fx.scan` semantics (emit `initial`, then fold each source value).
|
|
783
|
+
* Effect sampling accumulates across source versions via a private state ref (do not mix heavy
|
|
784
|
+
* subscribe + sample on the same scan if you need a single shared accumulator). The result remains
|
|
785
|
+
* a lazy view rather than a duplicated mutable value.
|
|
786
|
+
*
|
|
787
|
+
* ## Ownership and lifetime
|
|
788
|
+
*
|
|
789
|
+
* Each Effect Context object gets a private current-read accumulator, advanced after a successful
|
|
790
|
+
* fold for a new source version. The pushed channel runs `Fx.scanEffect` from `initial` inside
|
|
791
|
+
* `Subject.hold`: observers using the same Context share that active scan and retained result.
|
|
792
|
+
* The last observer ends its session and clears its held value. The observing Scope owns
|
|
793
|
+
* subscription cleanup. Read accumulators are weakly held by Context and need no finalizer.
|
|
794
|
+
*
|
|
795
|
+
* @since 1.0.0
|
|
796
|
+
* @category Accumulation
|
|
797
|
+
*/
|
|
798
|
+
export declare const scan: {
|
|
799
|
+
<S, A>(initial: S, f: (s: S, a: A) => S): <E, R>(ref: RefSubject<A, E, R> | Computed<A, E, R>) => Computed<S, E, R>;
|
|
800
|
+
<A, E, R, S>(ref: RefSubject<A, E, R> | Computed<A, E, R>, initial: S, f: (s: S, a: A) => S): Computed<S, E, R>;
|
|
801
|
+
<R0, E0, A, E, R, E2, R2, S>(versioned: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, initial: S, f: (s: S, a: A) => S): Computed<S, E0 | E | E2, R0 | R2 | Exclude<R, Scope.Scope>>;
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
804
|
+
* Effectful stateful scan over a `RefSubject` / `Computed`, producing a `Computed` of the accumulated state.
|
|
805
|
+
*
|
|
806
|
+
* @remarks
|
|
807
|
+
* ## Why
|
|
808
|
+
*
|
|
809
|
+
* Effectful stateful scan over a `RefSubject` / `Computed`, producing a `Computed` of the
|
|
810
|
+
* accumulated state. The result remains a lazy view rather than a duplicated mutable value.
|
|
811
|
+
*
|
|
812
|
+
* ## Ownership and lifetime
|
|
813
|
+
*
|
|
814
|
+
* Each Effect Context object gets a private current-read accumulator. It advances only after `f`
|
|
815
|
+
* succeeds, so a typed failure leaves the previous state intact. The pushed channel runs
|
|
816
|
+
* `Fx.scanEffect` from `initial` inside `Subject.hold`: observers using the same Context share
|
|
817
|
+
* that active scan and retained result; each fold requires `R3`. The last observer ends its
|
|
818
|
+
* session and clears its held value. The observing Scope owns cleanup. Read accumulators are
|
|
819
|
+
* weakly held by Context and need no finalizer.
|
|
820
|
+
*
|
|
821
|
+
* @since 1.0.0
|
|
822
|
+
* @category Accumulation
|
|
823
|
+
*/
|
|
824
|
+
export declare const scanEffect: {
|
|
825
|
+
<S, A, E3, R3>(initial: S, f: (s: S, a: A) => Effect.Effect<S, E3, R3>): <E, R>(ref: RefSubject<A, E, R> | Computed<A, E, R>) => Computed<S, E | E3, R | R3>;
|
|
826
|
+
<A, E, R, S, E3, R3>(ref: RefSubject<A, E, R> | Computed<A, E, R>, initial: S, f: (s: S, a: A) => Effect.Effect<S, E3, R3>): Computed<S, E | E3, R | R3>;
|
|
827
|
+
<R0, E0, A, E, R, E2, R2, S, E3, R3>(versioned: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, initial: S, f: (s: S, a: A) => Effect.Effect<S, E3, R3>): Computed<S, E0 | E | E2 | E3, R0 | R2 | R3 | Exclude<R, Scope.Scope>>;
|
|
828
|
+
};
|
|
829
|
+
/**
|
|
830
|
+
* Builds a Filtered view from the three channels of a Versioned source.
|
|
831
|
+
*
|
|
832
|
+
* @remarks
|
|
833
|
+
* ## Why
|
|
834
|
+
*
|
|
835
|
+
* Applies `f` to current reads and later pushes while preserving absence as Filtered semantics:
|
|
836
|
+
* Effect reads fail with `NoSuchElementError`, whereas the Fx channel simply omits absent values.
|
|
837
|
+
*
|
|
838
|
+
* ## Ownership and lifetime
|
|
839
|
+
*
|
|
840
|
+
* Sampled results and pushed sessions are isolated by Effect Context identity. Within one Context,
|
|
841
|
+
* current reads cache by source version and observers share the active held projection. Its
|
|
842
|
+
* Effect read fails with NoSuchElement while absent; the observing Scope owns its subscription.
|
|
843
|
+
*
|
|
844
|
+
* @since 1.18.0
|
|
845
|
+
* @category Optional queries
|
|
846
|
+
*/
|
|
234
847
|
export declare function makeFiltered<R0, E0, A, E, R, E2, R2, C, E3, R3>(input: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, f: (a: A) => Effect.Effect<Option.Option<C>, E3, R3>): Filtered<C, E0 | E | E2 | E3, R0 | Exclude<R, Scope.Scope> | R2 | R3>;
|
|
848
|
+
/**
|
|
849
|
+
* Defines the ref subject options state contract.
|
|
850
|
+
*
|
|
851
|
+
* @remarks
|
|
852
|
+
* ## Why
|
|
853
|
+
*
|
|
854
|
+
* Configures equality for committed RefSubject values.
|
|
855
|
+
*
|
|
856
|
+
* ## Ownership and lifetime
|
|
857
|
+
*
|
|
858
|
+
* RefSubjectOptions is a contract and performs no acquisition. Implementations retain the errors,
|
|
859
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
860
|
+
*
|
|
861
|
+
* @since 1.18.0
|
|
862
|
+
* @category Construction options
|
|
863
|
+
*/
|
|
235
864
|
export interface RefSubjectOptions<A> {
|
|
865
|
+
/**
|
|
866
|
+
* Optional equivalence used to suppress unchanged commits.
|
|
867
|
+
*
|
|
868
|
+
* @remarks
|
|
869
|
+
* ## Why
|
|
870
|
+
*
|
|
871
|
+
* Suppresses publication and version changes when a candidate value is equivalent to the
|
|
872
|
+
* currently committed value.
|
|
873
|
+
*
|
|
874
|
+
* ## Ownership and lifetime
|
|
875
|
+
*
|
|
876
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
877
|
+
* source errors, services, and lifetime.
|
|
878
|
+
*
|
|
879
|
+
* @since 1.18.0
|
|
880
|
+
* @category Equality
|
|
881
|
+
*/
|
|
236
882
|
readonly eq?: Equivalence<A>;
|
|
237
883
|
}
|
|
238
884
|
/**
|
|
239
885
|
* Creates a new `RefSubject` from a value, `Effect`, or `Fx`.
|
|
240
886
|
*
|
|
887
|
+
* @remarks
|
|
888
|
+
* ## Why
|
|
889
|
+
*
|
|
890
|
+
* `RefSubject` keeps current state and pushed changes independent of any UI
|
|
891
|
+
* renderer. Domain transitions can therefore be constructed, composed, and
|
|
892
|
+
* tested with Effect alone; rendering is one optional consumer of the state.
|
|
893
|
+
* Plain values, Effect programs, pull-based Effect `Stream`s, and push-based
|
|
894
|
+
* `Fx` sources all enter through the same state boundary.
|
|
895
|
+
*
|
|
896
|
+
* ## Ownership and lifetime
|
|
897
|
+
*
|
|
898
|
+
* Creation requires an Effect `Scope`. That scope owns source acquisition,
|
|
899
|
+
* subscriptions, and finalization. The returned `RefSubject` exposes the
|
|
900
|
+
* source error type when read or observed, while construction itself cannot
|
|
901
|
+
* fail. Closing the scope interrupts a live source and releases its resources.
|
|
902
|
+
*
|
|
903
|
+
* ## Initialization
|
|
904
|
+
*
|
|
905
|
+
* Calling `make` is lazy because it returns an Effect: nothing is allocated and no source runs
|
|
906
|
+
* until that creation Effect is executed. After creation, a plain value is immediately available.
|
|
907
|
+
* An Effect input runs once on the first current read or observation. Fx and Stream inputs instead
|
|
908
|
+
* start one shared source run when the creation Effect executes; reads wait for their first value
|
|
909
|
+
* or failure and later emissions replace the retained current state. Equality and buffering
|
|
910
|
+
* behavior can be customized with `RefSubjectOptions`.
|
|
911
|
+
*
|
|
241
912
|
* @example
|
|
242
913
|
* ```ts
|
|
243
914
|
* import { Effect } from "effect"
|
|
@@ -271,12 +942,25 @@ export interface RefSubjectOptions<A> {
|
|
|
271
942
|
* ```
|
|
272
943
|
*
|
|
273
944
|
* @since 1.0.0
|
|
274
|
-
* @category
|
|
945
|
+
* @category Constructors
|
|
275
946
|
*/
|
|
276
947
|
export declare function make<A, E = never, R = never>(effect: A | Effect.Effect<A, E, R> | Stream.Stream<A, E, R> | Fx<A, E, R>, options?: RefSubjectOptions<A>): Effect.Effect<RefSubject<A, E>, never, R | Scope.Scope>;
|
|
277
948
|
/**
|
|
278
949
|
* Creates a `RefSubject` from an `Effect`.
|
|
279
950
|
*
|
|
951
|
+
* @remarks
|
|
952
|
+
* ## Why
|
|
953
|
+
*
|
|
954
|
+
* Makes effect acquisition explicit while normalizing it into current RefSubject state and
|
|
955
|
+
* subsequent pushed versions.
|
|
956
|
+
*
|
|
957
|
+
* ## Ownership and lifetime
|
|
958
|
+
*
|
|
959
|
+
* The creation Effect requires Scope and the source's services, which it captures for the private
|
|
960
|
+
* initializer Scope. The source Effect itself stays deferred until the first current read or
|
|
961
|
+
* observation and runs at most once. Source failures remain visible on reads and observations;
|
|
962
|
+
* closing the creation Scope interrupts an initializer that is still running.
|
|
963
|
+
*
|
|
280
964
|
* @example
|
|
281
965
|
* ```ts
|
|
282
966
|
* import { Effect } from "effect"
|
|
@@ -293,12 +977,23 @@ export declare function make<A, E = never, R = never>(effect: A | Effect.Effect<
|
|
|
293
977
|
* ```
|
|
294
978
|
*
|
|
295
979
|
* @since 1.0.0
|
|
296
|
-
* @category
|
|
980
|
+
* @category Source adapters
|
|
297
981
|
*/
|
|
298
982
|
export declare function fromEffect<A, E, R>(effect: Effect.Effect<A, E, R>, options?: RefSubjectOptions<A>): Effect.Effect<RefSubject<A, E>, never, R | Scope.Scope>;
|
|
299
983
|
/**
|
|
300
984
|
* Creates a `RefSubject` from an `Fx`, tracking the latest emitted value.
|
|
301
985
|
*
|
|
986
|
+
* @remarks
|
|
987
|
+
* ## Why
|
|
988
|
+
*
|
|
989
|
+
* Makes fx acquisition explicit while normalizing it into current RefSubject state and subsequent
|
|
990
|
+
* pushed versions.
|
|
991
|
+
*
|
|
992
|
+
* ## Ownership and lifetime
|
|
993
|
+
*
|
|
994
|
+
* The creation Effect requires Scope. It owns initializer acquisition, live source subscriptions,
|
|
995
|
+
* and cleanup; source failures and services stay on reads and pushes.
|
|
996
|
+
*
|
|
302
997
|
* @example
|
|
303
998
|
* ```ts
|
|
304
999
|
* import { Effect } from "effect"
|
|
@@ -319,13 +1014,94 @@ export declare function fromEffect<A, E, R>(effect: Effect.Effect<A, E, R>, opti
|
|
|
319
1014
|
* ```
|
|
320
1015
|
*
|
|
321
1016
|
* @since 1.0.0
|
|
322
|
-
* @category
|
|
1017
|
+
* @category Source adapters
|
|
323
1018
|
*/
|
|
324
1019
|
export declare function fromFx<A, E, R>(fx: Fx<A, E, R>, options?: RefSubjectOptions<A>): Effect.Effect<RefSubject<A, E>, never, R | Scope.Scope>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Creates a RefSubject that tracks the latest value emitted by an Effect Stream.
|
|
1022
|
+
*
|
|
1023
|
+
* @remarks
|
|
1024
|
+
* ## Why
|
|
1025
|
+
*
|
|
1026
|
+
* Bridges a pull-based Stream into renderer-independent state: each emitted value enters the
|
|
1027
|
+
* RefSubject's serialized commit path, while a stream failure becomes the ref's current and pushed
|
|
1028
|
+
* failure.
|
|
1029
|
+
*
|
|
1030
|
+
* ## Ownership and lifetime
|
|
1031
|
+
*
|
|
1032
|
+
* Construction forks stream consumption immediately into the RefSubject's private Scope and cannot
|
|
1033
|
+
* fail. `R` is required while constructing that fiber; closing the outer Scope interrupts it.
|
|
1034
|
+
* Before the first value or failure, a current read waits for initialization. Later reads and pushes
|
|
1035
|
+
* expose `E`.
|
|
1036
|
+
*
|
|
1037
|
+
* @since 1.18.0
|
|
1038
|
+
* @category Source adapters
|
|
1039
|
+
*/
|
|
325
1040
|
export declare function fromStream<A, E, R>(stream: Stream.Stream<A, E, R>, options?: RefSubjectOptions<A>): Effect.Effect<RefSubject<A, E>, never, R | Scope.Scope>;
|
|
1041
|
+
/**
|
|
1042
|
+
* Creates a `RefSubject` from an `Option` value.
|
|
1043
|
+
*
|
|
1044
|
+
* @remarks
|
|
1045
|
+
* ## Why
|
|
1046
|
+
*
|
|
1047
|
+
* Stores the Option itself in writable state. `None` is an ordinary current value and does not add
|
|
1048
|
+
* `NoSuchElementError`; callers opt into absence semantics with `compact`, or a fallback with
|
|
1049
|
+
* `getOrElse`.
|
|
1050
|
+
*
|
|
1051
|
+
* ## Ownership and lifetime
|
|
1052
|
+
*
|
|
1053
|
+
* Construction requires Scope because it delegates to `make`, but the supplied Option needs no
|
|
1054
|
+
* services and cannot fail. The returned RefSubject owns and publishes subsequent Option writes.
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* ```ts
|
|
1058
|
+
* import { Effect, Option } from "effect"
|
|
1059
|
+
* import * as RefSubject from "@typed/fx/RefSubject"
|
|
1060
|
+
*
|
|
1061
|
+
* const program = Effect.gen(function* () {
|
|
1062
|
+
* const ref = yield* RefSubject.fromOption(Option.some(42))
|
|
1063
|
+
* const value = yield* ref
|
|
1064
|
+
* console.log(Option.isSome(value)) // true
|
|
1065
|
+
* })
|
|
1066
|
+
* ```
|
|
1067
|
+
*
|
|
1068
|
+
* @since 1.0.0
|
|
1069
|
+
* @category Source adapters
|
|
1070
|
+
*/
|
|
1071
|
+
export declare function fromOption<A>(option: Option.Option<A>, options?: RefSubjectOptions<Option.Option<A>>): Effect.Effect<RefSubject<Option.Option<A>>, never, Scope.Scope>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Creates Option-valued RefSubject state from a nullable input.
|
|
1074
|
+
*
|
|
1075
|
+
* @remarks
|
|
1076
|
+
* ## Why
|
|
1077
|
+
*
|
|
1078
|
+
* Converts `null` and `undefined` to `Option.none` and every other value to `Option.some`, then
|
|
1079
|
+
* stores that Option in a writable RefSubject. It does not create Filtered state or add
|
|
1080
|
+
* `NoSuchElementError`.
|
|
1081
|
+
*
|
|
1082
|
+
* ## Ownership and lifetime
|
|
1083
|
+
*
|
|
1084
|
+
* Construction requires Scope because it delegates to `make`; it needs no services and cannot
|
|
1085
|
+
* fail. The returned RefSubject owns and publishes subsequent Option writes.
|
|
1086
|
+
*
|
|
1087
|
+
* @since 1.18.0
|
|
1088
|
+
* @category Source adapters
|
|
1089
|
+
*/
|
|
1090
|
+
export declare function fromNullable<A>(value: A | null | undefined, options?: RefSubjectOptions<Option.Option<NonNullable<A>>>): Effect.Effect<RefSubject<Option.Option<NonNullable<A>>>, never, Scope.Scope>;
|
|
326
1091
|
/**
|
|
327
1092
|
* Sets the value of a `RefSubject`.
|
|
328
1093
|
*
|
|
1094
|
+
* @remarks
|
|
1095
|
+
* ## Why
|
|
1096
|
+
*
|
|
1097
|
+
* Sets the value of a `RefSubject`. The transition is serialized at the RefSubject rather than
|
|
1098
|
+
* coordinated by callers or UI components.
|
|
1099
|
+
*
|
|
1100
|
+
* ## Ownership and lifetime
|
|
1101
|
+
*
|
|
1102
|
+
* Running set performs one serialized subject transition and resolves with its committed value. It
|
|
1103
|
+
* acquires no resource; failures and services remain those of the source ref.
|
|
1104
|
+
*
|
|
329
1105
|
* @example
|
|
330
1106
|
* ```ts
|
|
331
1107
|
* import { Effect } from "effect"
|
|
@@ -347,7 +1123,7 @@ export declare function fromStream<A, E, R>(stream: Stream.Stream<A, E, R>, opti
|
|
|
347
1123
|
* ```
|
|
348
1124
|
*
|
|
349
1125
|
* @since 1.0.0
|
|
350
|
-
* @category
|
|
1126
|
+
* @category State updates
|
|
351
1127
|
*/
|
|
352
1128
|
export declare const set: {
|
|
353
1129
|
<A>(value: A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;
|
|
@@ -356,6 +1132,17 @@ export declare const set: {
|
|
|
356
1132
|
/**
|
|
357
1133
|
* Resets a `RefSubject` to its initial value, returning the previous value if it existed.
|
|
358
1134
|
*
|
|
1135
|
+
* @remarks
|
|
1136
|
+
* ## Why
|
|
1137
|
+
*
|
|
1138
|
+
* Resets a `RefSubject` to its initial value, returning the previous value if it existed. The
|
|
1139
|
+
* transition is serialized at the RefSubject rather than coordinated by callers or UI components.
|
|
1140
|
+
*
|
|
1141
|
+
* ## Ownership and lifetime
|
|
1142
|
+
*
|
|
1143
|
+
* Running reset performs one serialized subject transition and resolves with its committed value.
|
|
1144
|
+
* It acquires no resource; failures and services remain those of the source ref.
|
|
1145
|
+
*
|
|
359
1146
|
* @example
|
|
360
1147
|
* ```ts
|
|
361
1148
|
* import { Effect, Option } from "effect"
|
|
@@ -379,7 +1166,7 @@ export declare const set: {
|
|
|
379
1166
|
* ```
|
|
380
1167
|
*
|
|
381
1168
|
* @since 1.0.0
|
|
382
|
-
* @category
|
|
1169
|
+
* @category State updates
|
|
383
1170
|
*/
|
|
384
1171
|
export declare function reset<A, E, R>(ref: RefSubject<A, E, R>): Effect.Effect<Option.Option<A>, E, R>;
|
|
385
1172
|
export {
|
|
@@ -407,12 +1194,23 @@ export {
|
|
|
407
1194
|
* ```
|
|
408
1195
|
*
|
|
409
1196
|
* @since 1.20.0
|
|
410
|
-
* @category
|
|
1197
|
+
* @category State updates
|
|
411
1198
|
*/
|
|
412
1199
|
reset as delete, };
|
|
413
1200
|
/**
|
|
414
1201
|
* Updates a `RefSubject` using an `Effect`ful function.
|
|
415
1202
|
*
|
|
1203
|
+
* @remarks
|
|
1204
|
+
* ## Why
|
|
1205
|
+
*
|
|
1206
|
+
* Updates a `RefSubject` using an `Effect`ful function. The transition is serialized at the
|
|
1207
|
+
* RefSubject rather than coordinated by callers or UI components.
|
|
1208
|
+
*
|
|
1209
|
+
* ## Ownership and lifetime
|
|
1210
|
+
*
|
|
1211
|
+
* Running update effect performs one serialized subject transition and resolves with its committed
|
|
1212
|
+
* value. It acquires no resource; failures and services remain those of the source ref.
|
|
1213
|
+
*
|
|
416
1214
|
* @example
|
|
417
1215
|
* ```ts
|
|
418
1216
|
* import { Effect } from "effect"
|
|
@@ -432,7 +1230,7 @@ reset as delete, };
|
|
|
432
1230
|
* ```
|
|
433
1231
|
*
|
|
434
1232
|
* @since 1.0.0
|
|
435
|
-
* @category
|
|
1233
|
+
* @category State updates
|
|
436
1234
|
*/
|
|
437
1235
|
export declare const updateEffect: {
|
|
438
1236
|
<A, E2, R2>(f: (value: A) => Effect.Effect<A, E2, R2>): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E | E2, R | R2>;
|
|
@@ -441,6 +1239,26 @@ export declare const updateEffect: {
|
|
|
441
1239
|
/**
|
|
442
1240
|
* Updates a `RefSubject` using a pure function.
|
|
443
1241
|
*
|
|
1242
|
+
* @remarks
|
|
1243
|
+
* ## Why
|
|
1244
|
+
*
|
|
1245
|
+
* `update` expresses a state transition where the state lives, without moving
|
|
1246
|
+
* transition logic into a component or renderer. The same function can run in
|
|
1247
|
+
* application code, tests, workers, event handlers, or a Typed template.
|
|
1248
|
+
*
|
|
1249
|
+
* ## Ownership and lifetime
|
|
1250
|
+
*
|
|
1251
|
+
* The update runs inside the RefSubject's existing synchronized update
|
|
1252
|
+
* boundary: it reads the committed value, derives the next value, commits it,
|
|
1253
|
+
* and publishes that change. It acquires no independent resource and retains
|
|
1254
|
+
* the subject's existing error and service channels.
|
|
1255
|
+
*
|
|
1256
|
+
* ## Concurrency and failure
|
|
1257
|
+
*
|
|
1258
|
+
* Concurrent updates are serialized by the subject core so each function sees
|
|
1259
|
+
* a committed value. A pure updater adds no error channel; failures already
|
|
1260
|
+
* associated with reading or writing the RefSubject remain explicit in `E`.
|
|
1261
|
+
*
|
|
444
1262
|
* @example
|
|
445
1263
|
* ```ts
|
|
446
1264
|
* import { Effect } from "effect"
|
|
@@ -462,7 +1280,7 @@ export declare const updateEffect: {
|
|
|
462
1280
|
* ```
|
|
463
1281
|
*
|
|
464
1282
|
* @since 1.0.0
|
|
465
|
-
* @category
|
|
1283
|
+
* @category State updates
|
|
466
1284
|
*/
|
|
467
1285
|
export declare const update: {
|
|
468
1286
|
<A>(f: (value: A) => A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;
|
|
@@ -471,6 +1289,18 @@ export declare const update: {
|
|
|
471
1289
|
/**
|
|
472
1290
|
* Modifies a `RefSubject` using an `Effect`ful function that returns both a result and a new value.
|
|
473
1291
|
*
|
|
1292
|
+
* @remarks
|
|
1293
|
+
* ## Why
|
|
1294
|
+
*
|
|
1295
|
+
* Modifies a `RefSubject` using an `Effect`ful function that returns both a result and a new
|
|
1296
|
+
* value. The transition is serialized at the RefSubject rather than coordinated by callers or UI
|
|
1297
|
+
* components.
|
|
1298
|
+
*
|
|
1299
|
+
* ## Ownership and lifetime
|
|
1300
|
+
*
|
|
1301
|
+
* Running modify effect performs one serialized subject transition and resolves with its committed
|
|
1302
|
+
* value. It acquires no resource; failures and services remain those of the source ref.
|
|
1303
|
+
*
|
|
474
1304
|
* @example
|
|
475
1305
|
* ```ts
|
|
476
1306
|
* import { Effect } from "effect"
|
|
@@ -491,7 +1321,7 @@ export declare const update: {
|
|
|
491
1321
|
* ```
|
|
492
1322
|
*
|
|
493
1323
|
* @since 1.0.0
|
|
494
|
-
* @category
|
|
1324
|
+
* @category Transactions
|
|
495
1325
|
*/
|
|
496
1326
|
export declare const modifyEffect: {
|
|
497
1327
|
<A, B, E2, R2>(f: (value: A) => Effect.Effect<readonly [B, A], E2, R2>): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E | E2, R | R2>;
|
|
@@ -500,6 +1330,17 @@ export declare const modifyEffect: {
|
|
|
500
1330
|
/**
|
|
501
1331
|
* Modifies a `RefSubject` using a pure function that returns both a result and a new value.
|
|
502
1332
|
*
|
|
1333
|
+
* @remarks
|
|
1334
|
+
* ## Why
|
|
1335
|
+
*
|
|
1336
|
+
* Modifies a `RefSubject` using a pure function that returns both a result and a new value. The
|
|
1337
|
+
* transition is serialized at the RefSubject rather than coordinated by callers or UI components.
|
|
1338
|
+
*
|
|
1339
|
+
* ## Ownership and lifetime
|
|
1340
|
+
*
|
|
1341
|
+
* Running modify performs one serialized subject transition and resolves with its committed value.
|
|
1342
|
+
* It acquires no resource; failures and services remain those of the source ref.
|
|
1343
|
+
*
|
|
503
1344
|
* @example
|
|
504
1345
|
* ```ts
|
|
505
1346
|
* import { Effect } from "effect"
|
|
@@ -518,7 +1359,7 @@ export declare const modifyEffect: {
|
|
|
518
1359
|
* ```
|
|
519
1360
|
*
|
|
520
1361
|
* @since 1.0.0
|
|
521
|
-
* @category
|
|
1362
|
+
* @category Transactions
|
|
522
1363
|
*/
|
|
523
1364
|
export declare const modify: {
|
|
524
1365
|
<A, B>(f: (value: A) => readonly [B, A]): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<B, E, R>;
|
|
@@ -527,6 +1368,16 @@ export declare const modify: {
|
|
|
527
1368
|
/**
|
|
528
1369
|
* Checks if a value is a `RefSubject`.
|
|
529
1370
|
*
|
|
1371
|
+
* @remarks
|
|
1372
|
+
* ## Why
|
|
1373
|
+
*
|
|
1374
|
+
* Checks if a value is a `RefSubject`.
|
|
1375
|
+
*
|
|
1376
|
+
* ## Ownership and lifetime
|
|
1377
|
+
*
|
|
1378
|
+
* The derived ref owns no independent state or subscription. It follows the source lifetime and
|
|
1379
|
+
* routes writes through the source's synchronized update boundary.
|
|
1380
|
+
*
|
|
530
1381
|
* @example
|
|
531
1382
|
* ```ts
|
|
532
1383
|
* import { Effect } from "effect"
|
|
@@ -544,11 +1395,40 @@ export declare const modify: {
|
|
|
544
1395
|
* ```
|
|
545
1396
|
*
|
|
546
1397
|
* @since 1.0.0
|
|
547
|
-
* @category guards
|
|
1398
|
+
* @category Type guards
|
|
548
1399
|
*/
|
|
549
1400
|
export declare function isRefSubject(value: any): value is RefSubject<any, any, any>;
|
|
550
1401
|
/**
|
|
1402
|
+
* Tests whether a value carries the public Computed TypeId.
|
|
1403
|
+
*
|
|
1404
|
+
* @remarks
|
|
1405
|
+
* ## Why
|
|
1406
|
+
*
|
|
1407
|
+
* Uses the TypeId contract rather than a concrete implementation class, so custom Computed values
|
|
1408
|
+
* and service facades participate in the same runtime guard.
|
|
1409
|
+
*
|
|
1410
|
+
* ## Ownership and lifetime
|
|
1411
|
+
*
|
|
1412
|
+
* This synchronous predicate performs no Effect, subscription, or acquisition.
|
|
1413
|
+
*
|
|
1414
|
+
* @since 1.18.0
|
|
1415
|
+
* @category Type guards
|
|
1416
|
+
*/
|
|
1417
|
+
export declare function isComputed(value: any): value is Computed<any, any, any>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Runs an effect that can modify a `RefSubject` transactionally, with optional interrupt handling.
|
|
1420
|
+
*
|
|
1421
|
+
* @remarks
|
|
1422
|
+
* ## Why
|
|
1423
|
+
*
|
|
551
1424
|
* Runs an effect that can modify a `RefSubject` transactionally, with optional interrupt handling.
|
|
1425
|
+
* The transition is serialized at the RefSubject rather than coordinated by callers or UI
|
|
1426
|
+
* components.
|
|
1427
|
+
*
|
|
1428
|
+
* ## Ownership and lifetime
|
|
1429
|
+
*
|
|
1430
|
+
* Running run updates performs one serialized subject transition and resolves with its committed
|
|
1431
|
+
* value. It acquires no resource; failures and services remain those of the source ref.
|
|
552
1432
|
*
|
|
553
1433
|
* @example
|
|
554
1434
|
* ```ts
|
|
@@ -579,7 +1459,7 @@ export declare function isRefSubject(value: any): value is RefSubject<any, any,
|
|
|
579
1459
|
* ```
|
|
580
1460
|
*
|
|
581
1461
|
* @since 1.0.0
|
|
582
|
-
* @category
|
|
1462
|
+
* @category Transactions
|
|
583
1463
|
*/
|
|
584
1464
|
export declare const runUpdates: {
|
|
585
1465
|
<A, E, R, B, E2, R2, R3 = never, E3 = never, C = never>(f: (ref: GetSetDelete<A, E, R>) => Effect.Effect<B, E2, R2>, options?: {
|
|
@@ -589,11 +1469,22 @@ export declare const runUpdates: {
|
|
|
589
1469
|
<A, E, R, B, E2, R2, R3 = never, E3 = never, C = never>(ref: RefSubject<A, E, R>, f: (ref: GetSetDelete<A, E, R>) => Effect.Effect<B, E2, R2>, options?: {
|
|
590
1470
|
readonly onInterrupt: (value: A) => Effect.Effect<C, E3, R3>;
|
|
591
1471
|
readonly value?: "initial" | "current";
|
|
592
|
-
}
|
|
1472
|
+
}): Effect.Effect<B, E | E2 | E3, R | R2 | R3>;
|
|
593
1473
|
};
|
|
594
1474
|
/**
|
|
595
1475
|
* Increments a numeric `RefSubject` by 1.
|
|
596
1476
|
*
|
|
1477
|
+
* @remarks
|
|
1478
|
+
* ## Why
|
|
1479
|
+
*
|
|
1480
|
+
* Increments a numeric `RefSubject` by 1. The transition is serialized at the RefSubject rather
|
|
1481
|
+
* than coordinated by callers or UI components.
|
|
1482
|
+
*
|
|
1483
|
+
* ## Ownership and lifetime
|
|
1484
|
+
*
|
|
1485
|
+
* Running increment performs one serialized subject transition and resolves with its committed
|
|
1486
|
+
* value. It acquires no resource; failures and services remain those of the source ref.
|
|
1487
|
+
*
|
|
597
1488
|
* @example
|
|
598
1489
|
* ```ts
|
|
599
1490
|
* import { Effect } from "effect"
|
|
@@ -613,12 +1504,23 @@ export declare const runUpdates: {
|
|
|
613
1504
|
* ```
|
|
614
1505
|
*
|
|
615
1506
|
* @since 1.0.0
|
|
616
|
-
* @category
|
|
1507
|
+
* @category State updates
|
|
617
1508
|
*/
|
|
618
1509
|
export declare function increment<E, R>(ref: RefSubject<number, E, R>): Effect.Effect<number, E, R>;
|
|
619
1510
|
/**
|
|
620
1511
|
* Decrements a numeric `RefSubject` by 1.
|
|
621
1512
|
*
|
|
1513
|
+
* @remarks
|
|
1514
|
+
* ## Why
|
|
1515
|
+
*
|
|
1516
|
+
* Decrements a numeric `RefSubject` by 1. The transition is serialized at the RefSubject rather
|
|
1517
|
+
* than coordinated by callers or UI components.
|
|
1518
|
+
*
|
|
1519
|
+
* ## Ownership and lifetime
|
|
1520
|
+
*
|
|
1521
|
+
* Running decrement performs one serialized subject transition and resolves with its committed
|
|
1522
|
+
* value. It acquires no resource; failures and services remain those of the source ref.
|
|
1523
|
+
*
|
|
622
1524
|
* @example
|
|
623
1525
|
* ```ts
|
|
624
1526
|
* import { Effect } from "effect"
|
|
@@ -638,14 +1540,47 @@ export declare function increment<E, R>(ref: RefSubject<number, E, R>): Effect.E
|
|
|
638
1540
|
* ```
|
|
639
1541
|
*
|
|
640
1542
|
* @since 1.0.0
|
|
641
|
-
* @category
|
|
1543
|
+
* @category State updates
|
|
642
1544
|
*/
|
|
643
1545
|
export declare function decrement<E, R>(ref: RefSubject<number, E, R>): Effect.Effect<number, E, R>;
|
|
1546
|
+
/**
|
|
1547
|
+
* Creates a Context-backed RefSubject service facade and Layer constructors.
|
|
1548
|
+
*
|
|
1549
|
+
* @remarks
|
|
1550
|
+
* ## Why
|
|
1551
|
+
*
|
|
1552
|
+
* The returned class is simultaneously a service tag, a current-value Effect, an Fx source, and a
|
|
1553
|
+
* writable RefSubject facade. This lets consumers read, observe, and update renderer-independent
|
|
1554
|
+
* state without manually retrieving the underlying service from Context.
|
|
1555
|
+
*
|
|
1556
|
+
* ## Ownership and lifetime
|
|
1557
|
+
*
|
|
1558
|
+
* Calling `Service` is pure. `layer` installs an existing scoped RefSubject; `make` constructs one
|
|
1559
|
+
* and installs it in a Layer. The Layer Scope owns the subject and its initializer subscription.
|
|
1560
|
+
* Reads and pushes expose the declared `E` channel; construction requirements remain on the Layer,
|
|
1561
|
+
* while consumers require only the generated `Self` service.
|
|
1562
|
+
*
|
|
1563
|
+
* @since 1.18.0
|
|
1564
|
+
* @category Services
|
|
1565
|
+
*/
|
|
644
1566
|
export declare function Service<Self, A, E = never>(): <const Id extends string>(id: Id) => RefSubject.Class<Self, Id, A, E>;
|
|
645
1567
|
/**
|
|
646
1568
|
* Extract all values from an object using a Proxy.
|
|
647
1569
|
* Allows accessing nested properties of a `Computed` or `Filtered` object/array as individual computed values.
|
|
648
1570
|
*
|
|
1571
|
+
* @remarks
|
|
1572
|
+
* ## Why
|
|
1573
|
+
*
|
|
1574
|
+
* Lazily creates one property projection per accessed key and memoizes that projection on the
|
|
1575
|
+
* JavaScript Proxy. A Computed or RefSubject source produces Computed properties; only a Filtered
|
|
1576
|
+
* source produces Filtered properties and preserves conditional absence.
|
|
1577
|
+
*
|
|
1578
|
+
* ## Ownership and lifetime
|
|
1579
|
+
*
|
|
1580
|
+
* The Proxy caches derived view objects, not property values. Computed property reads expose only
|
|
1581
|
+
* the source's `E`; Filtered property reads can additionally fail with `NoSuchElementError` while
|
|
1582
|
+
* their source is absent. Each observed property follows the source and uses the observing Scope.
|
|
1583
|
+
*
|
|
649
1584
|
* @example
|
|
650
1585
|
* ```ts
|
|
651
1586
|
* import { Effect } from "effect"
|
|
@@ -674,7 +1609,7 @@ export declare function Service<Self, A, E = never>(): <const Id extends string>
|
|
|
674
1609
|
* ```
|
|
675
1610
|
*
|
|
676
1611
|
* @since 2.0.0
|
|
677
|
-
* @category
|
|
1612
|
+
* @category Derived queries
|
|
678
1613
|
*/
|
|
679
1614
|
export declare const proxy: {
|
|
680
1615
|
<A extends ReadonlyArray<any> | Readonly<Record<PropertyKey, any>>, E, R>(source: Computed<A, E, R>): {
|
|
@@ -684,13 +1619,91 @@ export declare const proxy: {
|
|
|
684
1619
|
readonly [K in keyof A]: Filtered<A[K], E, R>;
|
|
685
1620
|
};
|
|
686
1621
|
};
|
|
1622
|
+
/**
|
|
1623
|
+
* Describes the services type.
|
|
1624
|
+
*
|
|
1625
|
+
* @remarks
|
|
1626
|
+
* ## Why
|
|
1627
|
+
*
|
|
1628
|
+
* Extracts the service requirement channel from a RefSubject, Computed, or Filtered value.
|
|
1629
|
+
*
|
|
1630
|
+
* ## Ownership and lifetime
|
|
1631
|
+
*
|
|
1632
|
+
* Services is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
1633
|
+
* interruption, and Scope requirements expressed by its members.
|
|
1634
|
+
*
|
|
1635
|
+
* @since 1.18.0
|
|
1636
|
+
* @category Type utilities
|
|
1637
|
+
*/
|
|
687
1638
|
export type Services<T> = T extends RefSubject<infer _A, infer _E, infer R> ? R : T extends Computed<infer _A, infer _E, infer R> ? R : T extends Filtered<infer _A, infer _E, infer R> ? R : never;
|
|
1639
|
+
/**
|
|
1640
|
+
* Describes the error type.
|
|
1641
|
+
*
|
|
1642
|
+
* @remarks
|
|
1643
|
+
* ## Why
|
|
1644
|
+
*
|
|
1645
|
+
* Extracts the declared state error channel from a RefSubject, Computed, or Filtered value.
|
|
1646
|
+
*
|
|
1647
|
+
* ## Ownership and lifetime
|
|
1648
|
+
*
|
|
1649
|
+
* Error is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
1650
|
+
* interruption, and Scope requirements expressed by its members.
|
|
1651
|
+
*
|
|
1652
|
+
* @since 1.18.0
|
|
1653
|
+
* @category Type utilities
|
|
1654
|
+
*/
|
|
688
1655
|
export type Error<T> = T extends RefSubject<infer _A, infer E, infer _R> ? E : T extends Computed<infer _A, infer E, infer _R> ? E : T extends Filtered<infer _A, infer E, infer _R> ? E : never;
|
|
1656
|
+
/**
|
|
1657
|
+
* Describes the success type.
|
|
1658
|
+
*
|
|
1659
|
+
* @remarks
|
|
1660
|
+
* ## Why
|
|
1661
|
+
*
|
|
1662
|
+
* Extracts the current/read value type from a RefSubject, Computed, or Filtered value.
|
|
1663
|
+
*
|
|
1664
|
+
* ## Ownership and lifetime
|
|
1665
|
+
*
|
|
1666
|
+
* Success is a contract and performs no acquisition. Implementations retain the errors, services,
|
|
1667
|
+
* interruption, and Scope requirements expressed by its members.
|
|
1668
|
+
*
|
|
1669
|
+
* @since 1.18.0
|
|
1670
|
+
* @category Type utilities
|
|
1671
|
+
*/
|
|
689
1672
|
export type Success<T> = T extends RefSubject<infer A, infer _E, infer _R> ? A : T extends Computed<infer A, infer _E, infer _R> ? A : T extends Filtered<infer A, infer _E, infer _R> ? A : never;
|
|
1673
|
+
/**
|
|
1674
|
+
* Describes the identifier type.
|
|
1675
|
+
*
|
|
1676
|
+
* @remarks
|
|
1677
|
+
* ## Why
|
|
1678
|
+
*
|
|
1679
|
+
* Extracts the Context service identifier type represented by a RefSubject service facade.
|
|
1680
|
+
*
|
|
1681
|
+
* ## Ownership and lifetime
|
|
1682
|
+
*
|
|
1683
|
+
* Identifier is a contract and performs no acquisition. Implementations retain the errors,
|
|
1684
|
+
* services, interruption, and Scope requirements expressed by its members.
|
|
1685
|
+
*
|
|
1686
|
+
* @since 1.18.0
|
|
1687
|
+
* @category Type utilities
|
|
1688
|
+
*/
|
|
690
1689
|
export type Identifier<T> = T extends RefSubject.Service<infer R, infer _Id, infer _A, infer _E> ? R : never;
|
|
691
1690
|
/**
|
|
692
1691
|
* Transforms a `RefSubject`, `Computed`, or `Filtered` using an `Effect`ful function.
|
|
693
1692
|
*
|
|
1693
|
+
* @remarks
|
|
1694
|
+
* ## Why
|
|
1695
|
+
*
|
|
1696
|
+
* Applies one Effectful derivation to current reads and pushed versions. RefSubject and Computed
|
|
1697
|
+
* inputs return Computed and add only `E2`; a Filtered input returns Filtered and preserves its
|
|
1698
|
+
* conditional absence in addition to `E2`.
|
|
1699
|
+
*
|
|
1700
|
+
* ## Ownership and lifetime
|
|
1701
|
+
*
|
|
1702
|
+
* No callback runs until the result is read or observed. Computed results cannot become absent and
|
|
1703
|
+
* do not add `NoSuchElementError`; only the Filtered overload can fail a current read for absence.
|
|
1704
|
+
* Callback services and failures remain `R2` and `E2`, and the observing Scope owns subscription
|
|
1705
|
+
* cleanup.
|
|
1706
|
+
*
|
|
694
1707
|
* @example
|
|
695
1708
|
* ```ts
|
|
696
1709
|
* import { Effect } from "effect"
|
|
@@ -717,7 +1730,7 @@ export type Identifier<T> = T extends RefSubject.Service<infer R, infer _Id, inf
|
|
|
717
1730
|
* ```
|
|
718
1731
|
*
|
|
719
1732
|
* @since 1.0.0
|
|
720
|
-
* @category
|
|
1733
|
+
* @category Derived queries
|
|
721
1734
|
*/
|
|
722
1735
|
export declare const mapEffect: {
|
|
723
1736
|
<T extends RefSubject.Any | Computed.Any | Filtered.Any, B, E2, R2>(f: (a: Success<T>) => Effect.Effect<B, E2, R2>): (ref: T) => T extends Filtered.Any ? Filtered<B, Error<T> | E2, Services<T> | R2> : Computed<B, Error<T> | E2, Services<T> | R2>;
|
|
@@ -728,6 +1741,25 @@ export declare const mapEffect: {
|
|
|
728
1741
|
/**
|
|
729
1742
|
* Transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function.
|
|
730
1743
|
*
|
|
1744
|
+
* @remarks
|
|
1745
|
+
* ## Why
|
|
1746
|
+
*
|
|
1747
|
+
* `map` creates derived state instead of copying source state into a component.
|
|
1748
|
+
* Reads and pushed updates remain connected to the original `Versioned` value,
|
|
1749
|
+
* so a projection can be tested without rendering and consumed by any renderer.
|
|
1750
|
+
*
|
|
1751
|
+
* ## Ownership and lifetime
|
|
1752
|
+
*
|
|
1753
|
+
* The returned `Computed` or `Filtered` view does not take ownership of the
|
|
1754
|
+
* source. It follows the source lifetime and preserves its error and service
|
|
1755
|
+
* channels. The pure mapping function adds neither resources nor failures.
|
|
1756
|
+
*
|
|
1757
|
+
* ## Re-computation
|
|
1758
|
+
*
|
|
1759
|
+
* The mapping function runs for the current value and subsequent committed
|
|
1760
|
+
* source versions. Updates still occur on the writable source; the derived view
|
|
1761
|
+
* is read-only unless a more specific bidirectional combinator is used.
|
|
1762
|
+
*
|
|
731
1763
|
* @example
|
|
732
1764
|
* ```ts
|
|
733
1765
|
* import { Effect } from "effect"
|
|
@@ -752,7 +1784,7 @@ export declare const mapEffect: {
|
|
|
752
1784
|
* ```
|
|
753
1785
|
*
|
|
754
1786
|
* @since 1.0.0
|
|
755
|
-
* @category
|
|
1787
|
+
* @category Derived queries
|
|
756
1788
|
*/
|
|
757
1789
|
export declare const map: {
|
|
758
1790
|
<T extends RefSubject.Any | Computed.Any | Filtered.Any, B>(f: (a: Success<T>) => B): (ref: T) => T extends Filtered.Any ? Filtered<B, Error<T>, Services<T>> : Computed<B, Error<T>, Services<T>>;
|
|
@@ -763,6 +1795,18 @@ export declare const map: {
|
|
|
763
1795
|
/**
|
|
764
1796
|
* Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using an `Effect`ful function that returns an `Option`.
|
|
765
1797
|
*
|
|
1798
|
+
* @remarks
|
|
1799
|
+
* ## Why
|
|
1800
|
+
*
|
|
1801
|
+
* Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using an `Effect`ful function
|
|
1802
|
+
* that returns an `Option`. Current reads and pushed versions use the same derivation, preventing
|
|
1803
|
+
* snapshot and subscription behavior from diverging.
|
|
1804
|
+
*
|
|
1805
|
+
* ## Ownership and lifetime
|
|
1806
|
+
*
|
|
1807
|
+
* The filter map effect view retains no independent value. Its Effect read fails with NoSuchElement
|
|
1808
|
+
* while absent; the observing Scope owns and finalizes its Fx subscription.
|
|
1809
|
+
*
|
|
766
1810
|
* @example
|
|
767
1811
|
* ```ts
|
|
768
1812
|
* import { Effect, Option } from "effect"
|
|
@@ -782,7 +1826,7 @@ export declare const map: {
|
|
|
782
1826
|
* ```
|
|
783
1827
|
*
|
|
784
1828
|
* @since 1.0.0
|
|
785
|
-
* @category
|
|
1829
|
+
* @category Optional queries
|
|
786
1830
|
*/
|
|
787
1831
|
export declare const filterMapEffect: {
|
|
788
1832
|
<A, B, E2, R2>(f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>): {
|
|
@@ -796,6 +1840,18 @@ export declare const filterMapEffect: {
|
|
|
796
1840
|
/**
|
|
797
1841
|
* Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function that returns an `Option`.
|
|
798
1842
|
*
|
|
1843
|
+
* @remarks
|
|
1844
|
+
* ## Why
|
|
1845
|
+
*
|
|
1846
|
+
* Filters and transforms a `RefSubject`, `Computed`, or `Filtered` using a pure function that
|
|
1847
|
+
* returns an `Option`. Current reads and pushed versions use the same derivation, preventing
|
|
1848
|
+
* snapshot and subscription behavior from diverging.
|
|
1849
|
+
*
|
|
1850
|
+
* ## Ownership and lifetime
|
|
1851
|
+
*
|
|
1852
|
+
* The filter map view retains no independent value. Its Effect read fails with NoSuchElement
|
|
1853
|
+
* while absent; the observing Scope owns and finalizes its Fx subscription.
|
|
1854
|
+
*
|
|
799
1855
|
* @example
|
|
800
1856
|
* ```ts
|
|
801
1857
|
* import { Effect, Option } from "effect"
|
|
@@ -815,7 +1871,7 @@ export declare const filterMapEffect: {
|
|
|
815
1871
|
* ```
|
|
816
1872
|
*
|
|
817
1873
|
* @since 1.0.0
|
|
818
|
-
* @category
|
|
1874
|
+
* @category Optional queries
|
|
819
1875
|
*/
|
|
820
1876
|
export declare const filterMap: {
|
|
821
1877
|
<A, B>(f: (a: A) => Option.Option<B>): {
|
|
@@ -828,6 +1884,18 @@ export declare const filterMap: {
|
|
|
828
1884
|
/**
|
|
829
1885
|
* Converts a `Computed` or `Filtered` of `Option<A>` into a `Filtered<A>`, filtering out `None` values.
|
|
830
1886
|
*
|
|
1887
|
+
* @remarks
|
|
1888
|
+
* ## Why
|
|
1889
|
+
*
|
|
1890
|
+
* Converts a `Computed` or `Filtered` of `Option<A>` into a `Filtered<A>`, filtering out `None`
|
|
1891
|
+
* values. Current reads and pushed versions use the same derivation, preventing snapshot and
|
|
1892
|
+
* subscription behavior from diverging.
|
|
1893
|
+
*
|
|
1894
|
+
* ## Ownership and lifetime
|
|
1895
|
+
*
|
|
1896
|
+
* The compact view retains no independent value. Its Effect read fails with NoSuchElement
|
|
1897
|
+
* while absent; the observing Scope owns and finalizes its Fx subscription.
|
|
1898
|
+
*
|
|
831
1899
|
* @example
|
|
832
1900
|
* ```ts
|
|
833
1901
|
* import { Effect, Option } from "effect"
|
|
@@ -849,13 +1917,73 @@ export declare const filterMap: {
|
|
|
849
1917
|
* ```
|
|
850
1918
|
*
|
|
851
1919
|
* @since 1.0.0
|
|
852
|
-
* @category
|
|
1920
|
+
* @category Optional queries
|
|
853
1921
|
*/
|
|
854
1922
|
export declare const compact: {
|
|
855
|
-
<A, E, R>(ref: Computed<Option.Option<A>, E, R>): Filtered<A>;
|
|
856
|
-
<A, E, R>(ref: Filtered<Option.Option<A>, E, R>): Filtered<A>;
|
|
1923
|
+
<A, E, R>(ref: Computed<Option.Option<A>, E, R>): Filtered<A, E, R>;
|
|
1924
|
+
<A, E, R>(ref: Filtered<Option.Option<A>, E, R>): Filtered<A, E, R>;
|
|
857
1925
|
<R0, E0, A, E, R, E2, R2>(versioned: Versioned.Versioned<R0, E0, Option.Option<A>, E, R, Option.Option<A>, E2, R2>): Filtered<A, E0 | E | Exclude<E, Cause.NoSuchElementError> | Exclude<E2, Cause.NoSuchElementError>, R0 | R2 | Exclude<R, Scope.Scope>>;
|
|
858
1926
|
};
|
|
1927
|
+
/**
|
|
1928
|
+
* Returns a `Computed` that yields the value inside the `Option`, or the fallback when `None`.
|
|
1929
|
+
* Works with `Computed<Option<A>>` (e.g. from `fromOption` / `fromNullable`) and with `Filtered<A>`.
|
|
1930
|
+
*
|
|
1931
|
+
* @remarks
|
|
1932
|
+
* ## Why
|
|
1933
|
+
*
|
|
1934
|
+
* Returns a `Computed` that yields the value inside the `Option`, or the fallback when `None`.
|
|
1935
|
+
* Works with `Computed<Option<A>>` (e.g. from `fromOption` / `fromNullable`) and with
|
|
1936
|
+
* `Filtered<A>`. Current reads and pushed versions use the same derivation, preventing snapshot
|
|
1937
|
+
* and subscription behavior from diverging.
|
|
1938
|
+
*
|
|
1939
|
+
* ## Ownership and lifetime
|
|
1940
|
+
*
|
|
1941
|
+
* The returned Computed never fails for absence: `None` or an absent Filtered value invokes
|
|
1942
|
+
* `fallback`. It preserves only the input's declared `E` and `R`; the pure fallback adds no failure,
|
|
1943
|
+
* service, subscription, or retained value.
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```ts
|
|
1947
|
+
* import { Effect, Option } from "effect"
|
|
1948
|
+
* import * as RefSubject from "@typed/fx/RefSubject"
|
|
1949
|
+
*
|
|
1950
|
+
* const program = Effect.gen(function* () {
|
|
1951
|
+
* const ref = yield* RefSubject.fromOption(Option.some(42))
|
|
1952
|
+
* const withDefault = RefSubject.getOrElse(ref, () => 0)
|
|
1953
|
+
* expect(yield* withDefault).toBe(42)
|
|
1954
|
+
*
|
|
1955
|
+
* const empty = yield* RefSubject.fromNullable(null)
|
|
1956
|
+
* const fallback = RefSubject.getOrElse(empty, () => 99)
|
|
1957
|
+
* expect(yield* fallback).toBe(99)
|
|
1958
|
+
* })
|
|
1959
|
+
* ```
|
|
1960
|
+
*
|
|
1961
|
+
* @since 1.0.0
|
|
1962
|
+
* @category Optional queries
|
|
1963
|
+
*/
|
|
1964
|
+
export declare const getOrElse: {
|
|
1965
|
+
<A>(fallback: () => A): <E, R>(ref: Computed<Option.Option<A>, E, R> | Filtered<A, E, R>) => Computed<A, E, R>;
|
|
1966
|
+
<A, E, R>(ref: Computed<Option.Option<A>, E, R> | Filtered<A, E, R>, fallback: () => A): Computed<A, E, R>;
|
|
1967
|
+
};
|
|
1968
|
+
/**
|
|
1969
|
+
* Limits which pushed versions a RefSubject view observes without changing its state.
|
|
1970
|
+
*
|
|
1971
|
+
* @remarks
|
|
1972
|
+
* ## Why
|
|
1973
|
+
*
|
|
1974
|
+
* Applies `skip` and `take` only to the Fx observation channel. Current reads still sample the
|
|
1975
|
+
* underlying RefSubject directly, and writes still use its original serialized update boundary.
|
|
1976
|
+
*
|
|
1977
|
+
* ## Ownership and lifetime
|
|
1978
|
+
*
|
|
1979
|
+
* Creating the view starts nothing and retains no value. Each observation uses its Scope and ends
|
|
1980
|
+
* after `take` selected pushes; ending that observation does not interrupt or delete the source.
|
|
1981
|
+
* Version, interruption, subscriber count, reads, failures, services, and writes delegate to the
|
|
1982
|
+
* source RefSubject.
|
|
1983
|
+
*
|
|
1984
|
+
* @since 1.18.0
|
|
1985
|
+
* @category Observation policy
|
|
1986
|
+
*/
|
|
859
1987
|
export declare const slice: {
|
|
860
1988
|
(skip: number, take: number): <A, E, R>(ref: RefSubject<A, E, R>) => RefSubject<A, E, R>;
|
|
861
1989
|
<A, E, R>(ref: RefSubject<A, E, R>, skip: number, take: number): RefSubject<A, E, R>;
|
|
@@ -863,6 +1991,17 @@ export declare const slice: {
|
|
|
863
1991
|
/**
|
|
864
1992
|
* Transforms a `RefSubject` invariantly using bidirectional mapping functions.
|
|
865
1993
|
*
|
|
1994
|
+
* @remarks
|
|
1995
|
+
* ## Why
|
|
1996
|
+
*
|
|
1997
|
+
* Creates a bidirectional lens over state: reads map outward and writes map back to the original
|
|
1998
|
+
* RefSubject without allocating a second store.
|
|
1999
|
+
*
|
|
2000
|
+
* ## Ownership and lifetime
|
|
2001
|
+
*
|
|
2002
|
+
* The derived ref owns no independent state or subscription. It follows the source lifetime and
|
|
2003
|
+
* routes writes through the source's synchronized update boundary.
|
|
2004
|
+
*
|
|
866
2005
|
* @example
|
|
867
2006
|
* ```ts
|
|
868
2007
|
* import { Effect } from "effect"
|
|
@@ -891,14 +2030,16 @@ export declare const slice: {
|
|
|
891
2030
|
* ```
|
|
892
2031
|
*
|
|
893
2032
|
* @since 1.0.0
|
|
894
|
-
* @category
|
|
2033
|
+
* @category Writable views
|
|
895
2034
|
*/
|
|
896
2035
|
export declare const transform: {
|
|
897
2036
|
<A, B>(toB: (a: A) => B, toA: (b: B) => A): <E, R>(ref: RefSubject<A, E, R>) => RefSubject<B, E, R>;
|
|
898
2037
|
<A, E, R, B>(ref: RefSubject<A, E, R>, toB: (a: A) => B, toA: (b: B) => A): RefSubject<B, E, R>;
|
|
899
2038
|
};
|
|
900
2039
|
type RefKind = "r" | "c" | "f";
|
|
901
|
-
type StructFrom<Refs extends Readonly<Record<string, RefSubject.Any | Computed.Any | Filtered.Any>>> = {
|
|
2040
|
+
type StructFrom<Refs extends Readonly<Record<string, RefSubject.Any | Computed.Any | Filtered.Any>>> = [keyof Refs] extends [never] ? RefSubject<{
|
|
2041
|
+
readonly [K in keyof Refs]: never;
|
|
2042
|
+
}, never, never> : {
|
|
902
2043
|
c: [ComputedStructFrom<Refs>] extends [Computed<infer A, infer E, infer R>] ? Computed<A, E, R> : never;
|
|
903
2044
|
f: [FilteredStructFrom<Refs>] extends [Filtered<infer A, infer E, infer R>] ? Filtered<A, E, R> : never;
|
|
904
2045
|
r: [RefSubjectStructFrom<Refs>] extends [RefSubject<infer A, infer E, infer R>] ? RefSubject<A, E, R> : never;
|
|
@@ -922,7 +2063,7 @@ type ComputedStructFrom<Refs extends Readonly<Record<string, RefSubject.Any | Co
|
|
|
922
2063
|
type RefSubjectStructFrom<Refs extends Readonly<Record<string, RefSubject.Any | Computed.Any | Filtered.Any>>> = RefSubject<{
|
|
923
2064
|
readonly [K in keyof Refs]: Effect.Success<Refs[K]>;
|
|
924
2065
|
}, Effect.Error<Refs[keyof Refs]>, Effect.Services<Refs[keyof Refs]>>;
|
|
925
|
-
type TupleFrom<Refs extends ReadonlyArray<RefSubject<any, any, any> | Computed<any, any, any> | Filtered<any, any, any>>> = {
|
|
2066
|
+
type TupleFrom<Refs extends ReadonlyArray<RefSubject<any, any, any> | Computed<any, any, any> | Filtered<any, any, any>>> = Refs extends readonly [] ? RefSubject<readonly [], never, never> : {
|
|
926
2067
|
c: [ComputedTupleFrom<Refs>] extends [Computed<infer A, infer E, infer R>] ? Computed<A, E, R> : never;
|
|
927
2068
|
f: [FilteredTupleFrom<Refs>] extends [Filtered<infer A, infer E, infer R>] ? Filtered<A, E, R> : never;
|
|
928
2069
|
r: [RefSubjectTupleFrom<Refs>] extends [RefSubject<infer A, infer E, infer R>] ? RefSubject<A, E, R> : never;
|
|
@@ -940,6 +2081,17 @@ type RefSubjectTupleFrom<Refs extends ReadonlyArray<RefSubject<any, any, any> |
|
|
|
940
2081
|
/**
|
|
941
2082
|
* Combines multiple `RefSubject`, `Computed`, or `Filtered` instances into a single struct.
|
|
942
2083
|
*
|
|
2084
|
+
* @remarks
|
|
2085
|
+
* ## Why
|
|
2086
|
+
*
|
|
2087
|
+
* Combines several refs into one state value while preserving whether the result is writable,
|
|
2088
|
+
* computed, or filtered from its inputs.
|
|
2089
|
+
*
|
|
2090
|
+
* ## Ownership and lifetime
|
|
2091
|
+
*
|
|
2092
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
2093
|
+
* source errors, services, and lifetime.
|
|
2094
|
+
*
|
|
943
2095
|
* @example
|
|
944
2096
|
* ```ts
|
|
945
2097
|
* import { Effect } from "effect"
|
|
@@ -970,12 +2122,23 @@ type RefSubjectTupleFrom<Refs extends ReadonlyArray<RefSubject<any, any, any> |
|
|
|
970
2122
|
* ```
|
|
971
2123
|
*
|
|
972
2124
|
* @since 1.0.0
|
|
973
|
-
* @category
|
|
2125
|
+
* @category State composition
|
|
974
2126
|
*/
|
|
975
2127
|
export declare function struct<const Refs extends Readonly<Record<string, RefSubject.Any | Computed.Any | Filtered.Any>>>(refs: Refs): StructFrom<Refs>;
|
|
976
2128
|
/**
|
|
977
2129
|
* Combines multiple `RefSubject`, `Computed`, or `Filtered` instances into a single tuple.
|
|
978
2130
|
*
|
|
2131
|
+
* @remarks
|
|
2132
|
+
* ## Why
|
|
2133
|
+
*
|
|
2134
|
+
* Combines several refs into one state value while preserving whether the result is writable,
|
|
2135
|
+
* computed, or filtered from its inputs.
|
|
2136
|
+
*
|
|
2137
|
+
* ## Ownership and lifetime
|
|
2138
|
+
*
|
|
2139
|
+
* This declaration performs no acquisition and retains no resources. Implementations preserve
|
|
2140
|
+
* source errors, services, and lifetime.
|
|
2141
|
+
*
|
|
979
2142
|
* @example
|
|
980
2143
|
* ```ts
|
|
981
2144
|
* import { Effect } from "effect"
|
|
@@ -1002,9 +2165,45 @@ export declare function struct<const Refs extends Readonly<Record<string, RefSub
|
|
|
1002
2165
|
* ```
|
|
1003
2166
|
*
|
|
1004
2167
|
* @since 1.0.0
|
|
1005
|
-
* @category
|
|
2168
|
+
* @category State composition
|
|
1006
2169
|
*/
|
|
1007
2170
|
export declare function tuple<const Refs extends ReadonlyArray<Ref>>(refs: Refs): TupleFrom<Refs>;
|
|
2171
|
+
/**
|
|
2172
|
+
* Lifts an Effect-provided Computed into a Computed facade.
|
|
2173
|
+
*
|
|
2174
|
+
* @remarks
|
|
2175
|
+
* ## Why
|
|
2176
|
+
*
|
|
2177
|
+
* Defers service lookup until each version read, current read, interruption, or Fx observation, so
|
|
2178
|
+
* callers can compose a Context-provided Computed without manually flat-mapping the service Effect.
|
|
2179
|
+
*
|
|
2180
|
+
* ## Ownership and lifetime
|
|
2181
|
+
*
|
|
2182
|
+
* The facade caches neither the resolved Computed nor its value. Each operation runs the supplied
|
|
2183
|
+
* Effect, then delegates to the resolved Computed. Service requirements combine as `R | R2`, source
|
|
2184
|
+
* failures remain `E`, and the observing Scope owns the delegated subscription.
|
|
2185
|
+
*
|
|
2186
|
+
* @since 1.18.0
|
|
2187
|
+
* @category Services
|
|
2188
|
+
*/
|
|
1008
2189
|
export declare function computedFromService<R, A, E, R2>(effect: Effect.Effect<Computed<A, E, R2>, never, R>): Computed<A, E, R | R2>;
|
|
2190
|
+
/**
|
|
2191
|
+
* Defers retrieval of a Filtered value from Effect Context while preserving Filtered behavior.
|
|
2192
|
+
*
|
|
2193
|
+
* @remarks
|
|
2194
|
+
* ## Why
|
|
2195
|
+
*
|
|
2196
|
+
* Lets a service-provided Filtered participate directly in Effect reads and Fx observation without
|
|
2197
|
+
* manually flat-mapping the service tag at every use.
|
|
2198
|
+
*
|
|
2199
|
+
* ## Ownership and lifetime
|
|
2200
|
+
*
|
|
2201
|
+
* The filtered from service view retains no independent value. Its Effect read fails with NoSuchElement
|
|
2202
|
+
* while absent; the observing Scope owns and finalizes its Fx subscription.
|
|
2203
|
+
*
|
|
2204
|
+
* @since 1.18.0
|
|
2205
|
+
* @category Services
|
|
2206
|
+
*/
|
|
1009
2207
|
export declare function filteredFromService<R, A, E, R2>(effect: Effect.Effect<Filtered<A, E, R2>, never, R>): Filtered<A, E, R | R2>;
|
|
2208
|
+
export * from "./Hydration.js";
|
|
1010
2209
|
//# sourceMappingURL=RefSubject.d.ts.map
|