@typed/fx 2.0.0-beta.1 → 2.0.0-beta.11
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 +35 -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 +162 -11
- package/dist/Fx/combinators/additive.d.ts.map +1 -1
- package/dist/Fx/combinators/additive.js +162 -11
- package/dist/Fx/combinators/catch.d.ts +202 -29
- package/dist/Fx/combinators/catch.d.ts.map +1 -1
- package/dist/Fx/combinators/catch.js +193 -23
- 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 +21 -1
- package/dist/Fx/combinators/changesWithEffect.d.ts.map +1 -1
- package/dist/Fx/combinators/changesWithEffect.js +21 -1
- 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 +44 -2
- package/dist/Fx/combinators/dropUntil.d.ts.map +1 -1
- package/dist/Fx/combinators/dropUntil.js +44 -2
- 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 +48 -2
- 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 +35 -0
- package/dist/Fx/combinators/index.d.ts.map +1 -1
- package/dist/Fx/combinators/index.js +35 -0
- package/dist/Fx/combinators/keyed.d.ts +123 -9
- 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 +20 -1
- package/dist/Fx/combinators/mapBoth.d.ts.map +1 -1
- package/dist/Fx/combinators/mapBoth.js +20 -1
- 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 +21 -5
- package/dist/Fx/combinators/mapError.d.ts.map +1 -1
- package/dist/Fx/combinators/mapError.js +21 -5
- 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 +141 -20
- package/dist/Fx/combinators/provide.d.ts.map +1 -1
- package/dist/Fx/combinators/provide.js +137 -16
- 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 +23 -1
- package/dist/Fx/combinators/result.d.ts.map +1 -1
- package/dist/Fx/combinators/result.js +27 -13
- 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 +41 -2
- package/dist/Fx/combinators/scan.d.ts.map +1 -1
- package/dist/Fx/combinators/scan.js +43 -4
- 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 +33 -2
- package/dist/Fx/combinators/skip.d.ts.map +1 -1
- package/dist/Fx/combinators/skip.js +33 -2
- 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 +72 -4
- package/dist/Fx/combinators/skipWhile.d.ts.map +1 -1
- package/dist/Fx/combinators/skipWhile.js +72 -4
- package/dist/Fx/combinators/slice.d.ts +85 -3
- package/dist/Fx/combinators/slice.d.ts.map +1 -1
- package/dist/Fx/combinators/slice.js +35 -2
- 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 +34 -2
- package/dist/Fx/combinators/take.d.ts.map +1 -1
- package/dist/Fx/combinators/take.js +34 -2
- package/dist/Fx/combinators/takeUntil.d.ts +49 -3
- package/dist/Fx/combinators/takeUntil.d.ts.map +1 -1
- package/dist/Fx/combinators/takeUntil.js +49 -3
- package/dist/Fx/combinators/takeWhile.d.ts +33 -2
- package/dist/Fx/combinators/takeWhile.d.ts.map +1 -1
- package/dist/Fx/combinators/takeWhile.js +33 -2
- 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 +64 -4
- package/dist/Fx/combinators/zip.d.ts.map +1 -1
- package/dist/Fx/combinators/zip.js +64 -4
- package/dist/Fx/constructors/at.d.ts +21 -1
- 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 +30 -1
- 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 +70 -0
- package/dist/Fx/internal/effectableWithOverride.d.ts.map +1 -0
- package/dist/Fx/internal/effectableWithOverride.js +54 -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 +1229 -104
- package/dist/Push/Push.d.ts.map +1 -1
- package/dist/Push/Push.js +1024 -95
- 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 +133 -12
- 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 +1197 -45
- package/dist/RefSubject/RefSubject.d.ts.map +1 -1
- package/dist/RefSubject/RefSubject.js +935 -88
- 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 +740 -11
- package/dist/Sink/combinators.d.ts.map +1 -1
- package/dist/Sink/combinators.js +716 -14
- 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 +447 -27
- package/dist/Versioned/Versioned.d.ts.map +1 -1
- package/dist/Versioned/Versioned.js +282 -48
- package/dist/index.d.ts +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/package.json +126 -16
- 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/additive.ts +0 -142
- package/src/Fx/combinators/catch.ts +0 -421
- package/src/Fx/combinators/causes.ts +0 -23
- package/src/Fx/combinators/changesWithEffect.ts +0 -66
- package/src/Fx/combinators/compact.ts +0 -15
- package/src/Fx/combinators/continueWith.ts +0 -78
- package/src/Fx/combinators/dropUntil.ts +0 -47
- 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 -39
- 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 -61
- 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/mapBoth.ts +0 -40
- package/src/Fx/combinators/mapEffect.ts +0 -32
- package/src/Fx/combinators/mapError.ts +0 -28
- 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 -124
- package/src/Fx/combinators/result.ts +0 -39
- package/src/Fx/combinators/scan.ts +0 -82
- package/src/Fx/combinators/skip.ts +0 -41
- package/src/Fx/combinators/skipRepeats.ts +0 -15
- package/src/Fx/combinators/skipRepeatsWith.ts +0 -40
- package/src/Fx/combinators/skipWhile.ts +0 -100
- package/src/Fx/combinators/slice.ts +0 -55
- package/src/Fx/combinators/switchMap.ts +0 -55
- package/src/Fx/combinators/switchMapEffect.ts +0 -25
- package/src/Fx/combinators/take.ts +0 -38
- package/src/Fx/combinators/takeUntil.ts +0 -88
- package/src/Fx/combinators/takeWhile.ts +0 -47
- 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/combinators/zip.ts +0 -175
- 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.additive-combinators.test.ts +0 -126
- package/src/Fx.catch-additive.test.ts +0 -206
- package/src/Fx.catch.test.ts +0 -60
- package/src/Fx.dropUntil.test.ts +0 -61
- package/src/Fx.fn.test.ts +0 -51
- package/src/Fx.lifecycle.test.ts +0 -79
- package/src/Fx.mapError-mapBoth.test.ts +0 -101
- package/src/Fx.provide-combinators.test.ts +0 -94
- package/src/Fx.result-changesWithEffect.test.ts +0 -112
- package/src/Fx.scan.test.ts +0 -73
- package/src/Fx.takeWhile-skipWhile.test.ts +0 -84
- package/src/Fx.test.ts +0 -71
- package/src/Fx.ts +0 -1
- package/src/Fx.zip-merge-additive.test.ts +0 -171
- package/src/Fx.zip.test.ts +0 -133
- package/src/Push/Push.ts +0 -1072
- package/src/Push/index.ts +0 -1
- package/src/Push.additive.test.ts +0 -256
- 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 -2646
- 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.additive-parity.test.ts +0 -101
- 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 -1115
- package/src/Sink/index.ts +0 -2
- package/src/Sink.combinators.test.ts +0 -88
- package/src/Sink.reduce-collect-head-last.test.ts +0 -107
- 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 -597
- package/src/Versioned/index.ts +0 -1
- package/src/Versioned.filterMap.test.ts +0 -91
- package/src/Versioned.test.ts +0 -23
- package/src/Versioned.ts +0 -1
- package/src/index.ts +0 -7
package/dist/Push/Push.d.ts
CHANGED
|
@@ -4,13 +4,35 @@ import * as Effect from "effect/Effect";
|
|
|
4
4
|
import * as Layer from "effect/Layer";
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import type * as Scope from "effect/Scope";
|
|
7
|
-
import * as
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
8
|
import * as Fx from "../Fx/index.js";
|
|
9
9
|
import * as Sink from "../Sink.js";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* A bidirectional value that is both a `Sink<A, E, R>` and an `Fx<B, E2, R2>`.
|
|
12
|
+
*
|
|
13
|
+
* Calling `onSuccess` or `onFailure` sends exactly one input notification to the
|
|
14
|
+
* wrapped Sink. The returned `Effect` is the acknowledgment: a producer that runs
|
|
15
|
+
* and awaits it waits for the consumer callback to finish. `Push` adds no queue,
|
|
16
|
+
* buffering, replay, or demand protocol of its own.
|
|
17
|
+
*
|
|
18
|
+
* Running the Fx side preserves that Fx's cardinality and ordering. Input values
|
|
19
|
+
* are not automatically forwarded to the output; any relationship between the
|
|
20
|
+
* two sides belongs to the supplied Sink and Fx (for example, a shared `Subject`).
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* ## Why
|
|
24
|
+
*
|
|
25
|
+
* Interactive systems often need one value for sending work and another for
|
|
26
|
+
* observing results. Keeping both directions in one Effect-native value makes the
|
|
27
|
+
* boundary composable without pretending that commands and events are the same
|
|
28
|
+
* stream.
|
|
29
|
+
*
|
|
30
|
+
* ## Ownership and lifetime
|
|
31
|
+
*
|
|
32
|
+
* Constructing a `Push` starts no work and allocates no fiber or Scope. Each input
|
|
33
|
+
* callback runs in the caller's fiber with the Sink's `R` requirements. Running
|
|
34
|
+
* the output side follows the wrapped Fx's Scope, interruption, finalizers, `E2`
|
|
35
|
+
* failures, and `R2` services; `Push` does not change them.
|
|
14
36
|
*
|
|
15
37
|
* @example
|
|
16
38
|
* ```ts
|
|
@@ -42,23 +64,213 @@ import * as Sink from "../Sink.js";
|
|
|
42
64
|
* ```
|
|
43
65
|
*
|
|
44
66
|
* @since 1.0.0
|
|
45
|
-
* @category
|
|
67
|
+
* @category Bidirectional contracts
|
|
46
68
|
*/
|
|
47
69
|
export interface Push<in A, in E, out R, out B, out E2, out R2> extends Sink.Sink<A, E, R>, Fx.Fx<B, E2, R2> {
|
|
48
70
|
}
|
|
49
71
|
export declare namespace Push {
|
|
72
|
+
/**
|
|
73
|
+
* Matches any `Push` when its six channel types are intentionally unknown.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* ## Why
|
|
77
|
+
*
|
|
78
|
+
* Generic utilities sometimes need to inspect a Push before recovering its
|
|
79
|
+
* input, output, error, and service channels with conditional types.
|
|
80
|
+
*
|
|
81
|
+
* ## Ownership and lifetime
|
|
82
|
+
*
|
|
83
|
+
* This type alias creates no value or resource and changes no runtime lifetime.
|
|
84
|
+
*
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
* @category Type contracts
|
|
87
|
+
*/
|
|
50
88
|
type Any = Push<any, any, any, any, any, any>;
|
|
89
|
+
/**
|
|
90
|
+
* The static and Effect service surface returned by `Push.Service`.
|
|
91
|
+
*
|
|
92
|
+
* Service lookup supplies the same bidirectional value to `run`, `onSuccess`,
|
|
93
|
+
* and `onFailure`. The `Self` service appears in both required-service channels;
|
|
94
|
+
* the installed Push itself has those requirements captured by its Layer.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* ## Why
|
|
98
|
+
*
|
|
99
|
+
* A named service lets application code send inputs and observe outputs without
|
|
100
|
+
* threading a concrete Push through every function.
|
|
101
|
+
*
|
|
102
|
+
* ## Ownership and lifetime
|
|
103
|
+
*
|
|
104
|
+
* The Layer built by `make` owns service installation. It captures the Sink and
|
|
105
|
+
* Fx construction contexts, excluding `Scope.Scope`; Scope-dependent resources
|
|
106
|
+
* must therefore be acquired by the surrounding scoped program.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import * as Push from "@typed/fx/Push"
|
|
111
|
+
*
|
|
112
|
+
* class Events extends Push.Service<Events, string, never, string>()("Events") {}
|
|
113
|
+
* const id: "Events" = Events.id
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @since 1.0.0
|
|
117
|
+
* @category Push services
|
|
118
|
+
*/
|
|
51
119
|
interface Service<Self, Id extends string, A, E, B, E2> extends Push<A, E, Self, B, E2, Self> {
|
|
120
|
+
/**
|
|
121
|
+
* The literal Context service identifier supplied to `Push.Service`.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* ## Why
|
|
125
|
+
*
|
|
126
|
+
* A stable literal id makes the capability identifiable in Effect Context and
|
|
127
|
+
* diagnostics without inspecting its implementation.
|
|
128
|
+
*
|
|
129
|
+
* ## Ownership and lifetime
|
|
130
|
+
*
|
|
131
|
+
* The id is immutable metadata and owns no resource.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import * as Push from "@typed/fx/Push"
|
|
136
|
+
* class Events extends Push.Service<Events, string, never, string>()("Events") {}
|
|
137
|
+
* const id: "Events" = Events.id
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @since 1.0.0
|
|
141
|
+
* @category services
|
|
142
|
+
*/
|
|
52
143
|
readonly id: Id;
|
|
53
|
-
|
|
144
|
+
/**
|
|
145
|
+
* The Effect Context service used by the static Push operations.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* ## Why
|
|
149
|
+
*
|
|
150
|
+
* Exposing the Context service permits ordinary Effect service composition in
|
|
151
|
+
* addition to the convenience statics.
|
|
152
|
+
*
|
|
153
|
+
* ## Ownership and lifetime
|
|
154
|
+
*
|
|
155
|
+
* This is an immutable service reference. The Layer providing `Self`, not the
|
|
156
|
+
* reference, owns installation and release.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* import * as Push from "@typed/fx/Push"
|
|
161
|
+
* class Events extends Push.Service<Events, string, never, string>()("Events") {}
|
|
162
|
+
* const service = Events.service
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @since 1.0.0
|
|
166
|
+
* @category services
|
|
167
|
+
*/
|
|
168
|
+
readonly service: Context.Service<Self, Push<A, E, never, B, E2, never>>;
|
|
169
|
+
/**
|
|
170
|
+
* Builds a Layer that installs a concrete Sink/Fx pair as this service.
|
|
171
|
+
*
|
|
172
|
+
* Building the Layer starts neither side. The Sink context is captured at
|
|
173
|
+
* Layer construction; each output run additionally receives its subscriber's
|
|
174
|
+
* context.
|
|
175
|
+
*
|
|
176
|
+
* @remarks
|
|
177
|
+
* ## Why
|
|
178
|
+
*
|
|
179
|
+
* The Layer is the explicit composition boundary between implementation
|
|
180
|
+
* requirements and consumers that depend only on `Self`.
|
|
181
|
+
*
|
|
182
|
+
* ## Ownership and lifetime
|
|
183
|
+
*
|
|
184
|
+
* Layer lifetime owns service installation. `Scope.Scope` is excluded from
|
|
185
|
+
* captured requirements so scoped resources remain owned by the surrounding
|
|
186
|
+
* scoped Effect.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* import { Effect } from "effect"
|
|
191
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
192
|
+
* import * as Push from "@typed/fx/Push"
|
|
193
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
194
|
+
* class Events extends Push.Service<Events, string, never, string>()("Events") {}
|
|
195
|
+
* const Live = Events.make(Sink.make(() => Effect.void, () => Effect.void), Fx.succeed("ready"))
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @since 1.0.0
|
|
199
|
+
* @category layers
|
|
200
|
+
*/
|
|
54
201
|
readonly make: <R = never, R2 = never>(sink: Sink.Sink<A, E, R>, fx: Fx.Fx<B, E2, R2>) => Layer.Layer<Self, never, Exclude<R | R2, Scope.Scope>>;
|
|
55
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Constructable static type produced by `Push.Service`.
|
|
205
|
+
*
|
|
206
|
+
* @remarks
|
|
207
|
+
* ## Why
|
|
208
|
+
*
|
|
209
|
+
* The construct signature supports the class-extension pattern used by Effect
|
|
210
|
+
* services while retaining the complete static Push API.
|
|
211
|
+
*
|
|
212
|
+
* ## Ownership and lifetime
|
|
213
|
+
*
|
|
214
|
+
* Constructing the class returns its static service value; it does not acquire,
|
|
215
|
+
* subscribe to, or dispose the installed Push.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* import * as Push from "@typed/fx/Push"
|
|
220
|
+
*
|
|
221
|
+
* class Events extends Push.Service<Events, string, never, string>()("Events") {}
|
|
222
|
+
* const ServiceClass: Push.Push.Class<Events, "Events", string, never, string, never> = Events
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @since 1.0.0
|
|
226
|
+
* @category Push services
|
|
227
|
+
*/
|
|
56
228
|
interface Class<Self, Id extends string, A, E, B, E2> extends Service<Self, Id, A, E, B, E2> {
|
|
229
|
+
/**
|
|
230
|
+
* Returns the static service value when used through the class pattern.
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* ## Why
|
|
234
|
+
*
|
|
235
|
+
* The construct signature allows `class X extends Push.Service(...)` while
|
|
236
|
+
* preserving the service's precise static type.
|
|
237
|
+
*
|
|
238
|
+
* ## Ownership and lifetime
|
|
239
|
+
*
|
|
240
|
+
* Construction acquires nothing; the resulting value still resolves its
|
|
241
|
+
* concrete Push from the current Effect Context.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* import * as Push from "@typed/fx/Push"
|
|
246
|
+
* class Events extends Push.Service<Events, string, never, string>()("Events") {}
|
|
247
|
+
* const events = new Events()
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @since 1.0.0
|
|
251
|
+
* @category services
|
|
252
|
+
*/
|
|
57
253
|
new (): Service<Self, Id, A, E, B, E2>;
|
|
58
254
|
}
|
|
59
255
|
}
|
|
60
256
|
/**
|
|
61
|
-
*
|
|
257
|
+
* Couples a `Sink` input with an independent `Fx` output.
|
|
258
|
+
*
|
|
259
|
+
* The result forwards each input callback directly to `sink` and delegates every
|
|
260
|
+
* output subscription to `fx`. It does not connect the two values, change output
|
|
261
|
+
* cardinality or ordering, buffer inputs, or start either side eagerly.
|
|
262
|
+
*
|
|
263
|
+
* @remarks
|
|
264
|
+
* ## Why
|
|
265
|
+
*
|
|
266
|
+
* `make` is the explicit boundary where a command consumer and event producer
|
|
267
|
+
* become one bidirectional capability without hiding either contract.
|
|
268
|
+
*
|
|
269
|
+
* ## Ownership and lifetime
|
|
270
|
+
*
|
|
271
|
+
* Construction is allocation-free apart from the wrapper. Each input callback is
|
|
272
|
+
* owned by its caller; each output run is owned by the wrapped Fx run and inherits
|
|
273
|
+
* its interruption, Scope, cleanup, failures, and services.
|
|
62
274
|
*
|
|
63
275
|
* @example
|
|
64
276
|
* ```ts
|
|
@@ -67,92 +279,316 @@ export declare namespace Push {
|
|
|
67
279
|
* import { Fx } from "@typed/fx"
|
|
68
280
|
* import * as Sink from "@typed/fx/Sink"
|
|
69
281
|
*
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* const fx = Fx.succeed("Output")
|
|
282
|
+
* const received: Array<number> = []
|
|
283
|
+
* const sink = Sink.make(() => Effect.void, (value: number) =>
|
|
284
|
+
* Effect.sync(() => received.push(value))
|
|
285
|
+
* )
|
|
286
|
+
* const push = Push.make(sink, Fx.fromIterable(["ready", "done"]))
|
|
77
287
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* // Observe the Fx
|
|
85
|
-
* yield* Fx.observe(push, (value) =>
|
|
86
|
-
* Effect.sync(() => console.log("Emitted:", value))
|
|
87
|
-
* )
|
|
88
|
-
* // Output: "Emitted: Output"
|
|
89
|
-
* })
|
|
288
|
+
* const program = Effect.gen(function* () {
|
|
289
|
+
* yield* push.onSuccess(42) // acknowledges the Sink callback
|
|
290
|
+
* const output = yield* Fx.collectAll(push)
|
|
291
|
+
* return { received, output }
|
|
292
|
+
* }).pipe(Effect.scoped)
|
|
90
293
|
* ```
|
|
91
294
|
*
|
|
92
295
|
* @since 1.0.0
|
|
93
|
-
* @category
|
|
296
|
+
* @category Push construction
|
|
94
297
|
*/
|
|
95
298
|
export declare const make: {
|
|
96
299
|
<B, E2, R2>(fx: Fx.Fx<B, E2, R2>): <A, E, R>(sink: Sink.Sink<A, E, R>) => Push<A, E, R, B, E2, R2>;
|
|
97
300
|
<A, E, R, B, E2, R2>(sink: Sink.Sink<A, E, R>, fx: Fx.Fx<B, E2, R2>): Push<A, E, R, B, E2, R2>;
|
|
98
301
|
};
|
|
99
302
|
/**
|
|
100
|
-
*
|
|
303
|
+
* Synchronously transforms each successful input before sending it to the Sink.
|
|
304
|
+
*
|
|
305
|
+
* One input maps to exactly one downstream input. Calling `onSuccess` evaluates
|
|
306
|
+
* `f` immediately, before the returned downstream Effect is run; allocation and
|
|
307
|
+
* thrown exceptions therefore occur at callback invocation (and become defects
|
|
308
|
+
* only when that invocation itself occurs inside Effect evaluation). The Sink
|
|
309
|
+
* callback Effect remains the acknowledgment. Calls are not serialized; execution
|
|
310
|
+
* order and concurrency follow the producer. The Fx output is unchanged.
|
|
311
|
+
*
|
|
312
|
+
* @remarks
|
|
313
|
+
* ## Why
|
|
314
|
+
*
|
|
315
|
+
* Adapt an external command shape to an existing consumer without rebuilding or
|
|
316
|
+
* changing the independent output stream.
|
|
317
|
+
*
|
|
318
|
+
* ## Ownership and lifetime
|
|
319
|
+
*
|
|
320
|
+
* `f` runs synchronously when `onSuccess` is called, before its returned Effect
|
|
321
|
+
* exists, and acquires no resource. Downstream handling retains the original
|
|
322
|
+
* Sink's `E`, `R`, caller fiber, interruption, and cleanup behavior.
|
|
101
323
|
*
|
|
102
324
|
* @example
|
|
103
325
|
* ```ts
|
|
104
326
|
* import { Effect } from "effect"
|
|
327
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
105
328
|
* import * as Push from "@typed/fx/Push"
|
|
106
|
-
* import { Fx } from "@typed/fx"
|
|
107
329
|
* import * as Sink from "@typed/fx/Sink"
|
|
108
330
|
*
|
|
109
|
-
* const
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* )
|
|
117
|
-
*
|
|
118
|
-
* // Map input from string to number
|
|
119
|
-
* const mapped = Push.mapInput(push, (str: string) => parseInt(str))
|
|
120
|
-
*
|
|
121
|
-
* // Push a string, which gets converted to a number
|
|
122
|
-
* yield* mapped.onSuccess("42")
|
|
123
|
-
* // Output: "Number: 42"
|
|
331
|
+
* const events: Array<string> = []
|
|
332
|
+
* const base = Push.make(
|
|
333
|
+
* Sink.make(() => Effect.void, (n: number) => Effect.sync(() => events.push(`sink:${n}`))),
|
|
334
|
+
* Fx.empty
|
|
335
|
+
* )
|
|
336
|
+
* const mapped = Push.mapInput(base, (text: string) => {
|
|
337
|
+
* events.push(`map:${text}`)
|
|
338
|
+
* return Number(text)
|
|
124
339
|
* })
|
|
340
|
+
* const acknowledgement = mapped.onSuccess("42")
|
|
341
|
+
* // events is already ["map:42"]; the Sink Effect has not run yet.
|
|
342
|
+
* const program = Effect.as(acknowledgement, events)
|
|
125
343
|
* ```
|
|
126
344
|
*
|
|
127
345
|
* @since 1.0.0
|
|
128
|
-
* @category
|
|
346
|
+
* @category Transforming inputs
|
|
129
347
|
*/
|
|
130
348
|
export declare const mapInput: {
|
|
131
|
-
<
|
|
132
|
-
<
|
|
349
|
+
<C, A>(f: (c: C) => A): <E, R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<C, E, R, B, E2, R2>;
|
|
350
|
+
<A, E, R, B, E2, R2, C>(push: Push<A, E, R, B, E2, R2>, f: (c: C) => A): Push<C, E, R, B, E2, R2>;
|
|
133
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* Effectfully transforms each successful input before sending it to the Sink.
|
|
354
|
+
*
|
|
355
|
+
* Calling `onSuccess(value)` invokes `f(value)` immediately to construct an
|
|
356
|
+
* Effect. Allocation and thrown exceptions therefore occur before an
|
|
357
|
+
* acknowledgment Effect is returned. Running that returned Effect later executes
|
|
358
|
+
* the constructed Effect in the caller's fiber. On success its single `A` reaches
|
|
359
|
+
* the Sink; typed failure, defect, or interruption sends its full Cause to the
|
|
360
|
+
* Sink failure callback. Calls are not serialized, so the producer controls order
|
|
361
|
+
* and concurrency. Output values and order are unchanged.
|
|
362
|
+
*
|
|
363
|
+
* @remarks
|
|
364
|
+
* ## Why
|
|
365
|
+
*
|
|
366
|
+
* Use this at an input boundary that must decode, validate, or load Effect
|
|
367
|
+
* services before the existing consumer can accept a value.
|
|
368
|
+
*
|
|
369
|
+
* ## Ownership and lifetime
|
|
370
|
+
*
|
|
371
|
+
* Effect construction happens eagerly at `onSuccess`; only execution is deferred.
|
|
372
|
+
* The fiber running the returned acknowledgment owns execution and interruption
|
|
373
|
+
* of the constructed Effect and downstream callback. `E` is handled by the Sink
|
|
374
|
+
* failure channel, while `R3` joins the input service requirements.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* import { Effect } from "effect"
|
|
379
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
380
|
+
* import * as Push from "@typed/fx/Push"
|
|
381
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
382
|
+
*
|
|
383
|
+
* const numbers: Array<number> = []
|
|
384
|
+
* const base = Push.make(
|
|
385
|
+
* Sink.make(() => Effect.void, (n: number) => Effect.sync(() => numbers.push(n))),
|
|
386
|
+
* Fx.empty
|
|
387
|
+
* )
|
|
388
|
+
* const parsed = Push.mapInputEffect(base, (text: string) =>
|
|
389
|
+
* text === "" ? Effect.fail("empty" as const) : Effect.succeed(Number(text))
|
|
390
|
+
* )
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* @since 1.0.0
|
|
394
|
+
* @category Transforming inputs
|
|
395
|
+
*/
|
|
134
396
|
export declare const mapInputEffect: {
|
|
135
397
|
<C, R3, E, A>(f: (c: C) => Effect.Effect<A, E, R3>): <R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<C, E, R | R3, B, E2, R2>;
|
|
136
398
|
<A, E, R, B, E2, R2, R3, C>(push: Push<A, E, R, B, E2, R2>, f: (c: C) => Effect.Effect<A, E, R3>): Push<C, E, R | R3, B, E2, R2>;
|
|
137
399
|
};
|
|
400
|
+
/**
|
|
401
|
+
* Keeps successful inputs that satisfy `f` and discards the rest.
|
|
402
|
+
*
|
|
403
|
+
* Calling `onSuccess` runs the predicate immediately. A match constructs one Sink
|
|
404
|
+
* callback Effect; a non-match immediately returns an empty acknowledgment.
|
|
405
|
+
* Predicate allocation and throws therefore occur before the returned Effect is
|
|
406
|
+
* run. The producer controls call order and concurrency; output is preserved.
|
|
407
|
+
*
|
|
408
|
+
* @remarks
|
|
409
|
+
* ## Why
|
|
410
|
+
*
|
|
411
|
+
* Filtering before the consumer avoids teaching the underlying Sink about input
|
|
412
|
+
* values that are irrelevant to it.
|
|
413
|
+
*
|
|
414
|
+
* ## Ownership and lifetime
|
|
415
|
+
*
|
|
416
|
+
* The predicate is synchronous at `onSuccess` invocation and acquires no
|
|
417
|
+
* resources. Accepted callback Effects retain the original Sink's errors,
|
|
418
|
+
* services, interruption, and cleanup.
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* import { Effect } from "effect"
|
|
423
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
424
|
+
* import * as Push from "@typed/fx/Push"
|
|
425
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
426
|
+
*
|
|
427
|
+
* const checks: Array<number> = []
|
|
428
|
+
* const positives = Push.filterInput(
|
|
429
|
+
* Push.make(Sink.make(() => Effect.void, (n: number) => Effect.log(n)), Fx.empty),
|
|
430
|
+
* (n) => (checks.push(n), n > 0)
|
|
431
|
+
* )
|
|
432
|
+
* const acknowledgement = positives.onSuccess(-1)
|
|
433
|
+
* // checks is already [-1]; acknowledgement performs no Sink callback.
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @since 1.0.0
|
|
437
|
+
* @category Selecting inputs
|
|
438
|
+
*/
|
|
138
439
|
export declare const filterInput: {
|
|
139
|
-
<A>(f: (a: A) => boolean): <
|
|
440
|
+
<A>(f: (a: A) => boolean): <E, R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, B, E2, R2>;
|
|
140
441
|
<A, E, R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>, f: (a: A) => boolean): Push<A, E, R, B, E2, R2>;
|
|
141
442
|
};
|
|
443
|
+
/**
|
|
444
|
+
* Effectfully decides whether each successful input reaches the Sink.
|
|
445
|
+
*
|
|
446
|
+
* Calling `onSuccess(value)` invokes `f(value)` immediately to construct the
|
|
447
|
+
* predicate Effect; allocation and throws happen before an acknowledgment is
|
|
448
|
+
* returned. Running the acknowledgment later executes that Effect in the caller's
|
|
449
|
+
* fiber. `true` forwards one value, `false` none, and failure sends its Cause to
|
|
450
|
+
* the Sink failure callback. Calls are not serialized; the producer controls
|
|
451
|
+
* order and concurrency. Output behavior is unchanged.
|
|
452
|
+
*
|
|
453
|
+
* @remarks
|
|
454
|
+
* ## Why
|
|
455
|
+
*
|
|
456
|
+
* This supports authorization and service-backed eligibility checks directly at
|
|
457
|
+
* the consumer boundary.
|
|
458
|
+
*
|
|
459
|
+
* ## Ownership and lifetime
|
|
460
|
+
*
|
|
461
|
+
* Predicate Effect construction is eager; its execution and downstream callback
|
|
462
|
+
* belong to the fiber that runs the returned acknowledgment, whose interruption
|
|
463
|
+
* stops them. Predicate services join input `R`; typed `E` is consumed through
|
|
464
|
+
* the Sink failure channel.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```ts
|
|
468
|
+
* import { Effect } from "effect"
|
|
469
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
470
|
+
* import * as Push from "@typed/fx/Push"
|
|
471
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
472
|
+
*
|
|
473
|
+
* const even = Push.filterInputEffect(
|
|
474
|
+
* Push.make(Sink.make(() => Effect.void, (_n: number) => Effect.void), Fx.empty),
|
|
475
|
+
* (n) => Effect.succeed(n % 2 === 0)
|
|
476
|
+
* )
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @since 1.0.0
|
|
480
|
+
* @category Selecting inputs
|
|
481
|
+
*/
|
|
142
482
|
export declare const filterInputEffect: {
|
|
143
483
|
<A, R3, E>(f: (a: A) => Effect.Effect<boolean, E, R3>): <R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R | R3, B, E2, R2>;
|
|
144
484
|
<A, E, R, B, E2, R2, R3>(push: Push<A, E, R, B, E2, R2>, f: (a: A) => Effect.Effect<boolean, E, R3>): Push<A, E, R | R3, B, E2, R2>;
|
|
145
485
|
};
|
|
486
|
+
/**
|
|
487
|
+
* Transforms an input and forwards it only when `f` returns `Some`.
|
|
488
|
+
*
|
|
489
|
+
* Calling `onSuccess` evaluates `f` immediately. `Some(a)` constructs one Sink
|
|
490
|
+
* callback Effect; `None` immediately returns an empty acknowledgment. Mapping
|
|
491
|
+
* allocation and throws therefore happen before the returned Effect runs. Calls
|
|
492
|
+
* are not serialized, so ordering follows the producer. Output is unchanged.
|
|
493
|
+
*
|
|
494
|
+
* @remarks
|
|
495
|
+
* ## Why
|
|
496
|
+
*
|
|
497
|
+
* `Option` combines parsing and filtering without a sentinel value or a separate
|
|
498
|
+
* predicate pass.
|
|
499
|
+
*
|
|
500
|
+
* ## Ownership and lifetime
|
|
501
|
+
*
|
|
502
|
+
* The mapping is synchronous at `onSuccess` invocation and resource-free. A
|
|
503
|
+
* forwarded callback Effect retains the original Sink's lifetime, error channel,
|
|
504
|
+
* and service requirements.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* import { Effect, Option } from "effect"
|
|
509
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
510
|
+
* import * as Push from "@typed/fx/Push"
|
|
511
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
512
|
+
*
|
|
513
|
+
* const parsed: Array<string> = []
|
|
514
|
+
* const integers = Push.filterMapInput(
|
|
515
|
+
* Push.make(Sink.make(() => Effect.void, (n: number) => Effect.log(n)), Fx.empty),
|
|
516
|
+
* (text: string) => {
|
|
517
|
+
* parsed.push(text)
|
|
518
|
+
* return /^\d+$/.test(text) ? Option.some(Number(text)) : Option.none()
|
|
519
|
+
* }
|
|
520
|
+
* )
|
|
521
|
+
* const acknowledgement = integers.onSuccess("nope")
|
|
522
|
+
* // parsed is already ["nope"]; acknowledgement performs no Sink callback.
|
|
523
|
+
* ```
|
|
524
|
+
*
|
|
525
|
+
* @since 1.0.0
|
|
526
|
+
* @category Selecting inputs
|
|
527
|
+
*/
|
|
146
528
|
export declare const filterMapInput: {
|
|
147
|
-
<C, A>(f: (c: C) => Option.Option<A>): <P extends Push.Any>(push: P) => Push<C, Sink.Error<P>, Sink.
|
|
529
|
+
<C, A>(f: (c: C) => Option.Option<A>): <P extends Push.Any>(push: P) => Push<C, Sink.Error<P>, Sink.Services<P>, Fx.Fx.Success<P>, Fx.Fx.Error<P>, Fx.Fx.Services<P>>;
|
|
148
530
|
<A, E, R, B, E2, R2, C>(push: Push<A, E, R, B, E2, R2>, f: (c: C) => Option.Option<A>): Push<C, E, R, B, E2, R2>;
|
|
149
531
|
};
|
|
532
|
+
/**
|
|
533
|
+
* Effectfully transforms an input and forwards only a resulting `Some` value.
|
|
534
|
+
*
|
|
535
|
+
* Calling `onSuccess(value)` invokes `f(value)` immediately to construct an
|
|
536
|
+
* Effect; allocation and throws happen before an acknowledgment is returned.
|
|
537
|
+
* Running that acknowledgment later executes the constructed Effect in the
|
|
538
|
+
* caller's fiber. `Some(a)` produces one Sink callback, `None` none, and failure
|
|
539
|
+
* sends its full Cause to the Sink failure callback. Concurrent calls are not
|
|
540
|
+
* serialized.
|
|
541
|
+
*
|
|
542
|
+
* @remarks
|
|
543
|
+
* ## Why
|
|
544
|
+
*
|
|
545
|
+
* This is the input-boundary form for service-backed lookup or validation where
|
|
546
|
+
* absence is expected but failure remains meaningful.
|
|
547
|
+
*
|
|
548
|
+
* ## Ownership and lifetime
|
|
549
|
+
*
|
|
550
|
+
* Mapper Effect construction is eager; execution belongs to the fiber that runs
|
|
551
|
+
* the returned acknowledgment and can be interrupted there. Mapper requirements
|
|
552
|
+
* join the Sink input requirements; its `E` is handled through the same failure
|
|
553
|
+
* callback. The output Fx is untouched.
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* ```ts
|
|
557
|
+
* import { Effect, Option } from "effect"
|
|
558
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
559
|
+
* import * as Push from "@typed/fx/Push"
|
|
560
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
561
|
+
*
|
|
562
|
+
* const known = Push.filterMapInputEffect(
|
|
563
|
+
* Push.make(Sink.make(() => Effect.void, (_n: number) => Effect.void), Fx.empty),
|
|
564
|
+
* (text: string) => Effect.succeed(text === "one" ? Option.some(1) : Option.none())
|
|
565
|
+
* )
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @since 1.0.0
|
|
569
|
+
* @category Selecting inputs
|
|
570
|
+
*/
|
|
150
571
|
export declare const filterMapInputEffect: {
|
|
151
572
|
<C, R3, E, A>(f: (c: C) => Effect.Effect<Option.Option<A>, E, R3>): <R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<C, E, R | R3, B, E2, R2>;
|
|
152
573
|
<A, E, R, B, E2, R2, R3, C>(push: Push<A, E, R, B, E2, R2>, f: (c: C) => Effect.Effect<Option.Option<A>, E, R3>): Push<C, E, R | R3, B, E2, R2>;
|
|
153
574
|
};
|
|
154
575
|
/**
|
|
155
|
-
*
|
|
576
|
+
* Synchronously transforms every value emitted by the Fx output side.
|
|
577
|
+
*
|
|
578
|
+
* It emits exactly one `C` for every upstream `B`, preserving order and the
|
|
579
|
+
* complete input Sink. The mapping does not buffer or introduce concurrency.
|
|
580
|
+
*
|
|
581
|
+
* @remarks
|
|
582
|
+
* ## Why
|
|
583
|
+
*
|
|
584
|
+
* Adapt observed events without changing the commands the bidirectional boundary
|
|
585
|
+
* accepts.
|
|
586
|
+
*
|
|
587
|
+
* ## Ownership and lifetime
|
|
588
|
+
*
|
|
589
|
+
* `f` runs in the upstream Fx delivery path and owns no resource. Output
|
|
590
|
+
* subscription, interruption, failures, services, and cleanup remain those of the
|
|
591
|
+
* wrapped Fx and downstream Sink.
|
|
156
592
|
*
|
|
157
593
|
* @example
|
|
158
594
|
* ```ts
|
|
@@ -182,12 +618,45 @@ export declare const filterMapInputEffect: {
|
|
|
182
618
|
* ```
|
|
183
619
|
*
|
|
184
620
|
* @since 1.0.0
|
|
185
|
-
* @category
|
|
621
|
+
* @category Transforming outputs
|
|
186
622
|
*/
|
|
187
623
|
export declare const map: {
|
|
188
624
|
<B, C>(f: (b: B) => C): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2, R2>;
|
|
189
625
|
<A, E, R, B, E2, R2, C>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => C): Push<A, E, R, C, E2, R2>;
|
|
190
626
|
};
|
|
627
|
+
/**
|
|
628
|
+
* Effectfully transforms each Fx output value.
|
|
629
|
+
*
|
|
630
|
+
* The mapper runs once per upstream value and emits one result on success, in
|
|
631
|
+
* upstream order for a sequential source. Its typed failures join `E2`; its
|
|
632
|
+
* required services join `R2`. The input side is unchanged.
|
|
633
|
+
*
|
|
634
|
+
* @remarks
|
|
635
|
+
* ## Why
|
|
636
|
+
*
|
|
637
|
+
* Use this for output enrichment that needs Effect services or can fail while
|
|
638
|
+
* keeping input handling independent.
|
|
639
|
+
*
|
|
640
|
+
* ## Ownership and lifetime
|
|
641
|
+
*
|
|
642
|
+
* Each mapper Effect runs inside the output subscription and is interrupted with
|
|
643
|
+
* it. No work starts before `run`; cleanup belongs to the upstream Fx and mapper
|
|
644
|
+
* effects. `mapEffect` itself introduces no separate buffer or long-lived fiber.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```ts
|
|
648
|
+
* import { Effect } from "effect"
|
|
649
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
650
|
+
* import * as Push from "@typed/fx/Push"
|
|
651
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
652
|
+
*
|
|
653
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.succeed(2))
|
|
654
|
+
* const doubled = Push.mapEffect(push, (n) => Effect.succeed(n * 2))
|
|
655
|
+
* ```
|
|
656
|
+
*
|
|
657
|
+
* @since 1.0.0
|
|
658
|
+
* @category Transforming outputs
|
|
659
|
+
*/
|
|
191
660
|
export declare const mapEffect: {
|
|
192
661
|
<B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3>;
|
|
193
662
|
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3>;
|
|
@@ -198,10 +667,34 @@ export declare const mapEffect: {
|
|
|
198
667
|
* Failures (Cause) are mapped via `Cause.map`, so only the typed failure (`Fail`)
|
|
199
668
|
* is transformed; defects and interrupts are preserved unchanged.
|
|
200
669
|
*
|
|
201
|
-
* Mirrors `Effect.mapError` on the Fx side.
|
|
670
|
+
* Mirrors `Effect.mapError` on the Fx side. Cardinality, value order, input
|
|
671
|
+
* callbacks, and output service requirements are unchanged.
|
|
672
|
+
*
|
|
673
|
+
* @remarks
|
|
674
|
+
* ## Why
|
|
675
|
+
*
|
|
676
|
+
* Normalize an output failure type at the observation boundary without touching
|
|
677
|
+
* input errors or collapsing defects and interruption into typed failures.
|
|
678
|
+
*
|
|
679
|
+
* ## Ownership and lifetime
|
|
680
|
+
*
|
|
681
|
+
* The mapping is synchronous and resource-free. It runs when the output Cause is
|
|
682
|
+
* delivered and preserves the upstream subscription, Scope, interruption, and
|
|
683
|
+
* cleanup behavior.
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* ```ts
|
|
687
|
+
* import { Effect } from "effect"
|
|
688
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
689
|
+
* import * as Push from "@typed/fx/Push"
|
|
690
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
691
|
+
*
|
|
692
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.fail("offline"))
|
|
693
|
+
* const normalized = Push.mapError(push, (message) => ({ message }))
|
|
694
|
+
* ```
|
|
202
695
|
*
|
|
203
696
|
* @since 1.0.0
|
|
204
|
-
* @category
|
|
697
|
+
* @category Output failures
|
|
205
698
|
*/
|
|
206
699
|
export declare const mapError: {
|
|
207
700
|
<E2, E3>(f: (e: E2) => E3): <A, E, R, B, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, B, E3, R2>;
|
|
@@ -210,11 +703,37 @@ export declare const mapError: {
|
|
|
210
703
|
/**
|
|
211
704
|
* Transforms both the output (Fx) success and error channels of a `Push` using the provided options.
|
|
212
705
|
*
|
|
213
|
-
* Mirrors `Effect.mapBoth` on the Fx side: `onSuccess` maps emitted
|
|
214
|
-
* `onFailure` maps
|
|
706
|
+
* Mirrors `Effect.mapBoth` on the Fx side: `onSuccess` maps every emitted value
|
|
707
|
+
* one-to-one and `onFailure` maps typed failures via `Cause.map`; defects and
|
|
708
|
+
* interrupts are preserved. Ordering, services, and the input side are unchanged.
|
|
709
|
+
*
|
|
710
|
+
* @remarks
|
|
711
|
+
* ## Why
|
|
712
|
+
*
|
|
713
|
+
* Adapt both observable result channels at once while leaving command handling
|
|
714
|
+
* and non-typed Cause information intact.
|
|
715
|
+
*
|
|
716
|
+
* ## Ownership and lifetime
|
|
717
|
+
*
|
|
718
|
+
* Both functions run synchronously in the output delivery path and acquire no
|
|
719
|
+
* resources. The wrapped Fx retains ownership of its subscription and finalizers.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```ts
|
|
723
|
+
* import { Effect } from "effect"
|
|
724
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
725
|
+
* import * as Push from "@typed/fx/Push"
|
|
726
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
727
|
+
*
|
|
728
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.succeed(2))
|
|
729
|
+
* const labeled = Push.mapBoth(push, {
|
|
730
|
+
* onFailure: (error: never) => error,
|
|
731
|
+
* onSuccess: (value) => `value:${value}`
|
|
732
|
+
* })
|
|
733
|
+
* ```
|
|
215
734
|
*
|
|
216
735
|
* @since 1.0.0
|
|
217
|
-
* @category
|
|
736
|
+
* @category Transforming outputs
|
|
218
737
|
*/
|
|
219
738
|
export declare const mapBoth: {
|
|
220
739
|
<B, C, E2, E3>(options: {
|
|
@@ -226,132 +745,638 @@ export declare const mapBoth: {
|
|
|
226
745
|
readonly onSuccess: (b: B) => C;
|
|
227
746
|
}): Push<A, E, R, C, E3, R2>;
|
|
228
747
|
};
|
|
748
|
+
/**
|
|
749
|
+
* Keeps Fx output values that satisfy `f`.
|
|
750
|
+
*
|
|
751
|
+
* The upstream Sink invokes the predicate synchronously for each output value,
|
|
752
|
+
* before the returned downstream callback Effect runs. Predicate allocation and
|
|
753
|
+
* throws therefore occur at upstream callback invocation. Matches preserve their
|
|
754
|
+
* relative order; non-matches produce no output. No buffer is added and every
|
|
755
|
+
* input callback is unchanged.
|
|
756
|
+
*
|
|
757
|
+
* @remarks
|
|
758
|
+
* ## Why
|
|
759
|
+
*
|
|
760
|
+
* Restrict observed events without restricting which commands the Push accepts.
|
|
761
|
+
*
|
|
762
|
+
* ## Ownership and lifetime
|
|
763
|
+
*
|
|
764
|
+
* The predicate is synchronous at upstream `onSuccess` invocation and
|
|
765
|
+
* resource-free. Subscription, interruption, failures, services, and cleanup
|
|
766
|
+
* remain those of the wrapped Fx.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```ts
|
|
770
|
+
* import { Effect } from "effect"
|
|
771
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
772
|
+
* import * as Push from "@typed/fx/Push"
|
|
773
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
774
|
+
*
|
|
775
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.fromIterable([1, 2, 3]))
|
|
776
|
+
* const even = Push.filter(push, (n) => n % 2 === 0)
|
|
777
|
+
* ```
|
|
778
|
+
*
|
|
779
|
+
* @since 1.0.0
|
|
780
|
+
* @category Selecting outputs
|
|
781
|
+
*/
|
|
229
782
|
export declare const filter: {
|
|
230
783
|
<B>(f: (b: B) => boolean): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, B, E2, R2>;
|
|
231
784
|
<A, E, R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => boolean): Push<A, E, R, B, E2, R2>;
|
|
232
785
|
};
|
|
786
|
+
/**
|
|
787
|
+
* Effectfully decides which Fx output values are emitted.
|
|
788
|
+
*
|
|
789
|
+
* Each upstream value runs one predicate. `true` emits that value, `false` emits
|
|
790
|
+
* none, and predicate failures join the output error channel. For a sequential
|
|
791
|
+
* source the predicate is acknowledged before the next delivery, preserving
|
|
792
|
+
* order; the input side is unchanged.
|
|
793
|
+
*
|
|
794
|
+
* @remarks
|
|
795
|
+
* ## Why
|
|
796
|
+
*
|
|
797
|
+
* Use this when an observed event needs an Effect service or fallible check before
|
|
798
|
+
* it is visible downstream.
|
|
799
|
+
*
|
|
800
|
+
* ## Ownership and lifetime
|
|
801
|
+
*
|
|
802
|
+
* Predicate effects run inside and are interrupted with the output subscription.
|
|
803
|
+
* Their `E3` failures and `R3` services join the Fx channels. No separate queue or
|
|
804
|
+
* persistent fiber is introduced.
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* ```ts
|
|
808
|
+
* import { Effect } from "effect"
|
|
809
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
810
|
+
* import * as Push from "@typed/fx/Push"
|
|
811
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
812
|
+
*
|
|
813
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.fromIterable([1, 2]))
|
|
814
|
+
* const positive = Push.filterEffect(push, (n) => Effect.succeed(n > 0))
|
|
815
|
+
* ```
|
|
816
|
+
*
|
|
817
|
+
* @since 1.0.0
|
|
818
|
+
* @category Selecting outputs
|
|
819
|
+
*/
|
|
233
820
|
export declare const filterEffect: {
|
|
234
821
|
<B, R3, E3>(f: (b: B) => Effect.Effect<boolean, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, B, E2 | E3, R2 | R3>;
|
|
235
822
|
<A, E, R, B, E2, R2, R3, E3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<boolean, E3, R3>): Push<A, E, R, B, E2 | E3, R2 | R3>;
|
|
236
823
|
};
|
|
824
|
+
/**
|
|
825
|
+
* Maps each Fx output and emits only resulting `Some` values.
|
|
826
|
+
*
|
|
827
|
+
* The upstream Sink evaluates `f` synchronously for each value, before its
|
|
828
|
+
* returned downstream callback Effect runs. Mapping allocation and throws occur
|
|
829
|
+
* at that callback invocation. `Some(c)` emits exactly one `c`; `None` emits
|
|
830
|
+
* nothing. Relative order, errors, services, and input behavior are preserved.
|
|
831
|
+
*
|
|
832
|
+
* @remarks
|
|
833
|
+
* ## Why
|
|
834
|
+
*
|
|
835
|
+
* Combine output parsing and filtering without a sentinel value or a second pass.
|
|
836
|
+
*
|
|
837
|
+
* ## Ownership and lifetime
|
|
838
|
+
*
|
|
839
|
+
* The mapper is synchronous at upstream `onSuccess` invocation and resource-free.
|
|
840
|
+
* The wrapped Fx retains ownership of subscription, Scope, interruption, and
|
|
841
|
+
* finalizers.
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```ts
|
|
845
|
+
* import { Effect, Option } from "effect"
|
|
846
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
847
|
+
* import * as Push from "@typed/fx/Push"
|
|
848
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
849
|
+
*
|
|
850
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.fromIterable(["1", "x"]))
|
|
851
|
+
* const numbers = Push.filterMap(push, (text) => /^\d+$/.test(text) ? Option.some(Number(text)) : Option.none())
|
|
852
|
+
* ```
|
|
853
|
+
*
|
|
854
|
+
* @since 1.0.0
|
|
855
|
+
* @category Selecting outputs
|
|
856
|
+
*/
|
|
237
857
|
export declare const filterMap: {
|
|
238
858
|
<B, C>(f: (b: B) => Option.Option<C>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2, R2>;
|
|
239
859
|
<A, E, R, B, E2, R2, C>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Option.Option<C>): Push<A, E, R, C, E2, R2>;
|
|
240
860
|
};
|
|
861
|
+
/**
|
|
862
|
+
* Effectfully maps each Fx output and emits only resulting `Some` values.
|
|
863
|
+
*
|
|
864
|
+
* One mapper Effect runs per upstream value. `Some(c)` emits once, `None` emits
|
|
865
|
+
* nothing, and failures join the output error channel. Sequential sources retain
|
|
866
|
+
* order; the input Sink remains unchanged.
|
|
867
|
+
*
|
|
868
|
+
* @remarks
|
|
869
|
+
* ## Why
|
|
870
|
+
*
|
|
871
|
+
* This models service-backed lookup where absence is an ordinary filtered result
|
|
872
|
+
* but operational failure must remain observable.
|
|
873
|
+
*
|
|
874
|
+
* ## Ownership and lifetime
|
|
875
|
+
*
|
|
876
|
+
* Mapper effects are owned and interrupted by the output subscription. Their
|
|
877
|
+
* services join `R2` and failures join `E2`; the combinator adds no independent
|
|
878
|
+
* buffer or resource.
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```ts
|
|
882
|
+
* import { Effect, Option } from "effect"
|
|
883
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
884
|
+
* import * as Push from "@typed/fx/Push"
|
|
885
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
886
|
+
*
|
|
887
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.succeed("one"))
|
|
888
|
+
* const ids = Push.filterMapEffect(push, (name) => Effect.succeed(name === "one" ? Option.some(1) : Option.none()))
|
|
889
|
+
* ```
|
|
890
|
+
*
|
|
891
|
+
* @since 1.0.0
|
|
892
|
+
* @category Selecting outputs
|
|
893
|
+
*/
|
|
241
894
|
export declare const filterMapEffect: {
|
|
242
895
|
<B, C, E3, R3>(f: (b: B) => Effect.Effect<Option.Option<C>, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3>;
|
|
243
896
|
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<Option.Option<C>, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3>;
|
|
244
897
|
};
|
|
245
898
|
/**
|
|
246
|
-
* Transforms each output value into
|
|
899
|
+
* Transforms each output value into an inner `Fx`, observing only the latest one.
|
|
900
|
+
*
|
|
901
|
+
* A new outer value interrupts the previous inner fiber before starting the next.
|
|
902
|
+
* Output cardinality is the cardinality of the successive active inners; values
|
|
903
|
+
* from an interrupted inner stop. Outer order determines replacement order, while
|
|
904
|
+
* each active inner preserves its own order. The input Sink is unchanged.
|
|
905
|
+
*
|
|
906
|
+
* @remarks
|
|
907
|
+
* ## Why
|
|
908
|
+
*
|
|
909
|
+
* Latest-wins composition models search, navigation, and other work where a newer
|
|
910
|
+
* request makes the previous result irrelevant.
|
|
911
|
+
*
|
|
912
|
+
* ## Ownership and lifetime
|
|
913
|
+
*
|
|
914
|
+
* Running the result requires `Scope.Scope`. Each inner runs in that Scope and is
|
|
915
|
+
* interrupted on replacement or outer interruption; the last inner is joined
|
|
916
|
+
* before normal completion. Outer and inner errors/services are combined.
|
|
247
917
|
*
|
|
248
918
|
* @example
|
|
249
919
|
* ```ts
|
|
250
920
|
* import { Effect } from "effect"
|
|
921
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
251
922
|
* import * as Push from "@typed/fx/Push"
|
|
252
|
-
* import { Fx } from "@typed/fx"
|
|
253
923
|
* import * as Sink from "@typed/fx/Sink"
|
|
254
924
|
*
|
|
255
|
-
* const
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* ),
|
|
261
|
-
* Fx.succeed(1)
|
|
925
|
+
* const finalized: Array<number> = []
|
|
926
|
+
* const outer = Fx.make<number>((sink) =>
|
|
927
|
+
* sink.onSuccess(1).pipe(
|
|
928
|
+
* Effect.andThen(Effect.sleep("5 millis")),
|
|
929
|
+
* Effect.andThen(sink.onSuccess(2))
|
|
262
930
|
* )
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
931
|
+
* )
|
|
932
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), outer)
|
|
933
|
+
* const switched = Push.switchMap(push, (id) =>
|
|
934
|
+
* Fx.make<number>((sink) =>
|
|
935
|
+
* Effect.gen(function* () {
|
|
936
|
+
* yield* Effect.sleep("2 millis")
|
|
937
|
+
* yield* sink.onSuccess(id * 10 + 1)
|
|
938
|
+
* yield* Effect.sleep(id === 1 ? "20 millis" : "2 millis")
|
|
939
|
+
* yield* sink.onSuccess(id * 10 + 2)
|
|
940
|
+
* }).pipe(Effect.ensuring(Effect.sync(() => finalized.push(id))))
|
|
267
941
|
* )
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
* }
|
|
942
|
+
* )
|
|
943
|
+
* const program = Fx.collectAll(switched).pipe(
|
|
944
|
+
* Effect.map((values) => ({ values, finalized })),
|
|
945
|
+
* Effect.scoped
|
|
946
|
+
* )
|
|
947
|
+
* // Effect.runPromise(program) => { values: [11, 21, 22], finalized: [1, 2] }
|
|
274
948
|
* ```
|
|
275
949
|
*
|
|
276
950
|
* @since 1.0.0
|
|
277
|
-
* @category
|
|
951
|
+
* @category Concurrent output work
|
|
278
952
|
*/
|
|
279
953
|
export declare const switchMap: {
|
|
280
|
-
<B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R,
|
|
954
|
+
<B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
281
955
|
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
282
956
|
};
|
|
283
|
-
export declare const switchMapEffect: {
|
|
284
|
-
<B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, Scope.Scope | C, E2 | E3, R2 | R3>;
|
|
285
|
-
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, Scope.Scope | C, E2 | E3, R2 | R3>;
|
|
286
|
-
};
|
|
287
957
|
/**
|
|
288
|
-
* Transforms each output value into
|
|
958
|
+
* Transforms each output value into an Effect, keeping only the latest Effect.
|
|
959
|
+
*
|
|
960
|
+
* Each new outer value interrupts the previous Effect before starting its own.
|
|
961
|
+
* Every Effect can emit at most one value; interrupted Effects emit none. The
|
|
962
|
+
* input side is unchanged.
|
|
963
|
+
*
|
|
964
|
+
* @remarks
|
|
965
|
+
* ## Why
|
|
966
|
+
*
|
|
967
|
+
* This is latest-wins Effect composition without manually wrapping each Effect as
|
|
968
|
+
* an Fx.
|
|
969
|
+
*
|
|
970
|
+
* ## Ownership and lifetime
|
|
971
|
+
*
|
|
972
|
+
* The output subscription's Scope owns the active Effect fiber. Replacement and
|
|
973
|
+
* subscription interruption run its interruption/finalizers. `E3` joins output
|
|
974
|
+
* errors and `R3` joins required services.
|
|
289
975
|
*
|
|
290
976
|
* @example
|
|
291
977
|
* ```ts
|
|
292
978
|
* import { Effect } from "effect"
|
|
979
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
293
980
|
* import * as Push from "@typed/fx/Push"
|
|
294
|
-
* import { Fx } from "@typed/fx"
|
|
295
981
|
* import * as Sink from "@typed/fx/Sink"
|
|
296
982
|
*
|
|
297
|
-
* const
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* ),
|
|
303
|
-
* Fx.succeed(1)
|
|
983
|
+
* const finalized: Array<number> = []
|
|
984
|
+
* const source = Fx.make<number>((sink) =>
|
|
985
|
+
* sink.onSuccess(1).pipe(
|
|
986
|
+
* Effect.andThen(Effect.sleep("2 millis")),
|
|
987
|
+
* Effect.andThen(sink.onSuccess(2))
|
|
304
988
|
* )
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
989
|
+
* )
|
|
990
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), source)
|
|
991
|
+
* const latest = Push.switchMapEffect(push, (id) =>
|
|
992
|
+
* Effect.sleep(id === 1 ? "20 millis" : "1 millis").pipe(
|
|
993
|
+
* Effect.as(id),
|
|
994
|
+
* Effect.ensuring(Effect.sync(() => finalized.push(id)))
|
|
309
995
|
* )
|
|
996
|
+
* )
|
|
997
|
+
* const program = Fx.collectAll(latest).pipe(
|
|
998
|
+
* Effect.map((values) => ({ values, finalized })),
|
|
999
|
+
* Effect.scoped
|
|
1000
|
+
* )
|
|
1001
|
+
* // Effect.runPromise(program) => { values: [2], finalized: [1, 2] }
|
|
1002
|
+
* ```
|
|
310
1003
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
|
|
1004
|
+
* @since 1.0.0
|
|
1005
|
+
* @category Concurrent output work
|
|
1006
|
+
*/
|
|
1007
|
+
export declare const switchMapEffect: {
|
|
1008
|
+
<B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
1009
|
+
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
1010
|
+
};
|
|
1011
|
+
/**
|
|
1012
|
+
* Transforms each output value into an inner `Fx` and merges all inners concurrently.
|
|
1013
|
+
*
|
|
1014
|
+
* Every outer value starts one inner. All inner values are emitted; order within
|
|
1015
|
+
* each inner is preserved, but values from different inners may interleave. The
|
|
1016
|
+
* outer stream waits for all inners before normal completion. The input Sink is
|
|
1017
|
+
* unchanged.
|
|
1018
|
+
*
|
|
1019
|
+
* @remarks
|
|
1020
|
+
* ## Why
|
|
1021
|
+
*
|
|
1022
|
+
* Use concurrent flattening when every produced task matters and independent work
|
|
1023
|
+
* should overlap.
|
|
1024
|
+
*
|
|
1025
|
+
* ## Ownership and lifetime
|
|
1026
|
+
*
|
|
1027
|
+
* The output Scope owns a fiber set containing all active inners. Outer
|
|
1028
|
+
* interruption interrupts that set and runs inner cleanup. Inner failures and
|
|
1029
|
+
* services join the outer Fx channels; no ordering buffer is added.
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* import { Effect } from "effect"
|
|
1034
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1035
|
+
* import * as Push from "@typed/fx/Push"
|
|
1036
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1037
|
+
*
|
|
1038
|
+
* const finalized: Array<number> = []
|
|
1039
|
+
* const push = Push.make(
|
|
1040
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1041
|
+
* Fx.fromIterable([1, 2])
|
|
1042
|
+
* )
|
|
1043
|
+
* const merged = Push.flatMap(push, (id) =>
|
|
1044
|
+
* Fx.make<number>((sink) =>
|
|
1045
|
+
* Effect.gen(function* () {
|
|
1046
|
+
* yield* Effect.sleep(id === 1 ? "5 millis" : "10 millis")
|
|
1047
|
+
* yield* sink.onSuccess(id * 10 + 1)
|
|
1048
|
+
* yield* Effect.sleep("20 millis")
|
|
1049
|
+
* yield* sink.onSuccess(id * 10 + 2)
|
|
1050
|
+
* }).pipe(Effect.ensuring(Effect.sync(() => finalized.push(id))))
|
|
314
1051
|
* )
|
|
315
|
-
*
|
|
1052
|
+
* )
|
|
1053
|
+
* const program = Fx.collectAll(merged).pipe(
|
|
1054
|
+
* Effect.map((values) => ({ values, finalized })),
|
|
1055
|
+
* Effect.scoped
|
|
1056
|
+
* )
|
|
1057
|
+
* // Effect.runPromise(program) => { values: [11, 21, 12, 22], finalized: [1, 2] }
|
|
316
1058
|
* ```
|
|
317
1059
|
*
|
|
318
1060
|
* @since 1.0.0
|
|
319
|
-
* @category
|
|
1061
|
+
* @category Concurrent output work
|
|
320
1062
|
*/
|
|
321
1063
|
export declare const flatMap: {
|
|
322
1064
|
<B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
323
1065
|
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
324
1066
|
};
|
|
1067
|
+
/**
|
|
1068
|
+
* Transforms every output value into an Effect and merges their results concurrently.
|
|
1069
|
+
*
|
|
1070
|
+
* One Effect starts per outer value and can emit one result. All successful
|
|
1071
|
+
* results are emitted, but concurrent completion order may differ from input
|
|
1072
|
+
* order. The input side is unchanged.
|
|
1073
|
+
*
|
|
1074
|
+
* @remarks
|
|
1075
|
+
* ## Why
|
|
1076
|
+
*
|
|
1077
|
+
* This runs independent Effect work concurrently without manually lifting each
|
|
1078
|
+
* Effect into Fx.
|
|
1079
|
+
*
|
|
1080
|
+
* ## Ownership and lifetime
|
|
1081
|
+
*
|
|
1082
|
+
* Active Effects are fibers owned by the output Scope. Completion waits for all
|
|
1083
|
+
* of them; interruption stops them and runs their finalizers. `E3` and `R3` join
|
|
1084
|
+
* the output failure and service channels.
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ```ts
|
|
1088
|
+
* import { Effect } from "effect"
|
|
1089
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1090
|
+
* import * as Push from "@typed/fx/Push"
|
|
1091
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1092
|
+
*
|
|
1093
|
+
* const finalized: Array<number> = []
|
|
1094
|
+
* const push = Push.make(
|
|
1095
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1096
|
+
* Fx.fromIterable([1, 2])
|
|
1097
|
+
* )
|
|
1098
|
+
* const loaded = Push.flatMapEffect(push, (id) =>
|
|
1099
|
+
* Effect.sleep(id === 1 ? "20 millis" : "1 millis").pipe(
|
|
1100
|
+
* Effect.as(id),
|
|
1101
|
+
* Effect.ensuring(Effect.sync(() => finalized.push(id)))
|
|
1102
|
+
* )
|
|
1103
|
+
* )
|
|
1104
|
+
* const program = Fx.collectAll(loaded).pipe(
|
|
1105
|
+
* Effect.map((values) => ({ values, finalized })),
|
|
1106
|
+
* Effect.scoped
|
|
1107
|
+
* )
|
|
1108
|
+
* // Effect.runPromise(program) => { values: [2, 1], finalized: [2, 1] }
|
|
1109
|
+
* ```
|
|
1110
|
+
*
|
|
1111
|
+
* @since 1.0.0
|
|
1112
|
+
* @category Concurrent output work
|
|
1113
|
+
*/
|
|
325
1114
|
export declare const flatMapEffect: {
|
|
326
1115
|
<B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
327
|
-
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R,
|
|
1116
|
+
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
328
1117
|
};
|
|
1118
|
+
/**
|
|
1119
|
+
* Runs at most one inner Fx and ignores outer values while it is active.
|
|
1120
|
+
*
|
|
1121
|
+
* The first value seen while idle starts an inner; every value arriving before
|
|
1122
|
+
* that inner completes is dropped. `f(value)` is still evaluated and its inner Fx
|
|
1123
|
+
* is constructed before the busy check; dropping means the returned Fx is not
|
|
1124
|
+
* run. Accepted inners preserve their own order and all values. Input is unchanged.
|
|
1125
|
+
*
|
|
1126
|
+
* @remarks
|
|
1127
|
+
* ## Why
|
|
1128
|
+
*
|
|
1129
|
+
* Exhaust semantics prevent duplicate work, such as repeated submit clicks, while
|
|
1130
|
+
* allowing another request after the active one completes.
|
|
1131
|
+
*
|
|
1132
|
+
* ## Ownership and lifetime
|
|
1133
|
+
*
|
|
1134
|
+
* The output Scope owns the active inner fiber, joins it before completion, and
|
|
1135
|
+
* interrupts it with the subscription. Inner failures and services join the
|
|
1136
|
+
* outer channels; there is no pending-value buffer.
|
|
1137
|
+
*
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```ts
|
|
1140
|
+
* import { Effect } from "effect"
|
|
1141
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1142
|
+
* import * as Push from "@typed/fx/Push"
|
|
1143
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1144
|
+
*
|
|
1145
|
+
* const constructed: Array<number> = []
|
|
1146
|
+
* const started: Array<number> = []
|
|
1147
|
+
* const finalized: Array<number> = []
|
|
1148
|
+
* const push = Push.make(
|
|
1149
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1150
|
+
* Fx.fromIterable([1, 2])
|
|
1151
|
+
* )
|
|
1152
|
+
* const exhausted = Push.exhaustMap(push, (id) => {
|
|
1153
|
+
* constructed.push(id)
|
|
1154
|
+
* return Fx.make<number>((sink) =>
|
|
1155
|
+
* Effect.gen(function* () {
|
|
1156
|
+
* yield* Effect.sync(() => started.push(id))
|
|
1157
|
+
* yield* Effect.sleep("5 millis")
|
|
1158
|
+
* yield* sink.onSuccess(id * 10 + 1)
|
|
1159
|
+
* yield* Effect.sleep("5 millis")
|
|
1160
|
+
* yield* sink.onSuccess(id * 10 + 2)
|
|
1161
|
+
* }).pipe(Effect.ensuring(Effect.sync(() => finalized.push(id))))
|
|
1162
|
+
* )
|
|
1163
|
+
* })
|
|
1164
|
+
* const program = Fx.collectAll(exhausted).pipe(
|
|
1165
|
+
* Effect.map((values) => ({ values, constructed, started, finalized })),
|
|
1166
|
+
* Effect.scoped
|
|
1167
|
+
* )
|
|
1168
|
+
* // => { values: [11, 12], constructed: [1, 2], started: [1], finalized: [1] }
|
|
1169
|
+
* ```
|
|
1170
|
+
*
|
|
1171
|
+
* @since 1.0.0
|
|
1172
|
+
* @category Concurrent output work
|
|
1173
|
+
*/
|
|
329
1174
|
export declare const exhaustMap: {
|
|
330
1175
|
<B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
331
1176
|
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
332
1177
|
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Runs at most one mapped Effect and ignores values while it is active.
|
|
1180
|
+
*
|
|
1181
|
+
* The first value while idle starts one Effect and can emit one result; all values
|
|
1182
|
+
* received before it completes are dropped. The mapping callback is still invoked
|
|
1183
|
+
* and constructs an Effect for every value before the busy check; dropped Effects
|
|
1184
|
+
* are not run. The input side is unchanged.
|
|
1185
|
+
*
|
|
1186
|
+
* @remarks
|
|
1187
|
+
* ## Why
|
|
1188
|
+
*
|
|
1189
|
+
* This guards non-overlapping Effect work without manual busy state.
|
|
1190
|
+
*
|
|
1191
|
+
* ## Ownership and lifetime
|
|
1192
|
+
*
|
|
1193
|
+
* The output Scope owns and joins the active Effect fiber. Subscription
|
|
1194
|
+
* interruption stops it and runs finalizers. Its errors and services join the
|
|
1195
|
+
* output channels; no value is buffered for later.
|
|
1196
|
+
*
|
|
1197
|
+
* @example
|
|
1198
|
+
* ```ts
|
|
1199
|
+
* import { Effect } from "effect"
|
|
1200
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1201
|
+
* import * as Push from "@typed/fx/Push"
|
|
1202
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1203
|
+
*
|
|
1204
|
+
* const constructed: Array<number> = []
|
|
1205
|
+
* const finalized: Array<number> = []
|
|
1206
|
+
* const push = Push.make(
|
|
1207
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1208
|
+
* Fx.fromIterable([1, 2])
|
|
1209
|
+
* )
|
|
1210
|
+
* const saving = Push.exhaustMapEffect(push, (id) => {
|
|
1211
|
+
* constructed.push(id)
|
|
1212
|
+
* return Effect.sleep("10 millis").pipe(
|
|
1213
|
+
* Effect.as(id),
|
|
1214
|
+
* Effect.ensuring(Effect.sync(() => finalized.push(id)))
|
|
1215
|
+
* )
|
|
1216
|
+
* })
|
|
1217
|
+
* const program = Fx.collectAll(saving).pipe(
|
|
1218
|
+
* Effect.map((values) => ({ values, constructed, finalized })),
|
|
1219
|
+
* Effect.scoped
|
|
1220
|
+
* )
|
|
1221
|
+
* // Effect.runPromise(program) => { values: [1], constructed: [1, 2], finalized: [1] }
|
|
1222
|
+
* ```
|
|
1223
|
+
*
|
|
1224
|
+
* @since 1.0.0
|
|
1225
|
+
* @category Concurrent output work
|
|
1226
|
+
*/
|
|
333
1227
|
export declare const exhaustMapEffect: {
|
|
334
1228
|
<B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
335
|
-
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R,
|
|
1229
|
+
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
336
1230
|
};
|
|
1231
|
+
/**
|
|
1232
|
+
* Runs one inner Fx at a time and retains only the latest value received while busy.
|
|
1233
|
+
*
|
|
1234
|
+
* A value while idle starts immediately. While its inner runs, newer outer values
|
|
1235
|
+
* replace a single pending slot. `f(value)` is evaluated and an inner Fx is
|
|
1236
|
+
* constructed before every replacement; a superseded pending Fx is never run.
|
|
1237
|
+
* After completion, only the latest pending Fx starts. Accepted inners preserve
|
|
1238
|
+
* their own order and all values. The input Sink is unchanged.
|
|
1239
|
+
*
|
|
1240
|
+
* @remarks
|
|
1241
|
+
* ## Why
|
|
1242
|
+
*
|
|
1243
|
+
* This is useful when work must not overlap but the newest requested state must
|
|
1244
|
+
* eventually be processed.
|
|
1245
|
+
*
|
|
1246
|
+
* ## Ownership and lifetime
|
|
1247
|
+
*
|
|
1248
|
+
* The output Scope owns one active inner fiber and an in-memory latest slot. It
|
|
1249
|
+
* joins the final inner before completion and interrupts it with the subscription.
|
|
1250
|
+
* Inner failures and services join the output channels.
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```ts
|
|
1254
|
+
* import { Effect } from "effect"
|
|
1255
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1256
|
+
* import * as Push from "@typed/fx/Push"
|
|
1257
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1258
|
+
*
|
|
1259
|
+
* const constructed: Array<number> = []
|
|
1260
|
+
* const started: Array<number> = []
|
|
1261
|
+
* const finalized: Array<number> = []
|
|
1262
|
+
* const push = Push.make(
|
|
1263
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1264
|
+
* Fx.fromIterable([1, 2, 3])
|
|
1265
|
+
* )
|
|
1266
|
+
* const latest = Push.exhaustLatestMap(push, (id) => {
|
|
1267
|
+
* constructed.push(id)
|
|
1268
|
+
* return Fx.make<number>((sink) =>
|
|
1269
|
+
* Effect.gen(function* () {
|
|
1270
|
+
* yield* Effect.sync(() => started.push(id))
|
|
1271
|
+
* yield* Effect.sleep("5 millis")
|
|
1272
|
+
* yield* sink.onSuccess(id * 10 + 1)
|
|
1273
|
+
* yield* Effect.sleep("5 millis")
|
|
1274
|
+
* yield* sink.onSuccess(id * 10 + 2)
|
|
1275
|
+
* }).pipe(Effect.ensuring(Effect.sync(() => finalized.push(id))))
|
|
1276
|
+
* )
|
|
1277
|
+
* })
|
|
1278
|
+
* const program = Fx.collectAll(latest).pipe(
|
|
1279
|
+
* Effect.map((values) => ({ values, constructed, started, finalized })),
|
|
1280
|
+
* Effect.scoped
|
|
1281
|
+
* )
|
|
1282
|
+
* // => values [11, 12, 31, 32]; constructed [1, 2, 3]; started/finalized [1, 3].
|
|
1283
|
+
* ```
|
|
1284
|
+
*
|
|
1285
|
+
* @since 1.0.0
|
|
1286
|
+
* @category Concurrent output work
|
|
1287
|
+
*/
|
|
337
1288
|
export declare const exhaustLatestMap: {
|
|
338
1289
|
<B, C, E3, R3>(f: (b: B) => Fx.Fx<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
339
1290
|
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Fx.Fx<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
340
1291
|
};
|
|
1292
|
+
/**
|
|
1293
|
+
* Runs one mapped Effect at a time and retains only the latest value received while busy.
|
|
1294
|
+
*
|
|
1295
|
+
* Each accepted Effect can emit one result. While it runs, one pending Effect is
|
|
1296
|
+
* repeatedly overwritten; after completion only the latest pending Effect starts.
|
|
1297
|
+
* The mapping callback still runs and constructs an Effect for every value before
|
|
1298
|
+
* replacement; superseded Effects are not run. The input side is unchanged.
|
|
1299
|
+
*
|
|
1300
|
+
* @remarks
|
|
1301
|
+
* ## Why
|
|
1302
|
+
*
|
|
1303
|
+
* This provides non-overlapping Effect work with eventual latest-state handling,
|
|
1304
|
+
* avoiding an unbounded queue of obsolete requests.
|
|
1305
|
+
*
|
|
1306
|
+
* ## Ownership and lifetime
|
|
1307
|
+
*
|
|
1308
|
+
* The output Scope owns the active Effect fiber and pending slot. It waits for the
|
|
1309
|
+
* final Effect, interrupts it with the subscription, and runs its finalizers.
|
|
1310
|
+
* Effect failures and services join the output channels.
|
|
1311
|
+
*
|
|
1312
|
+
* @example
|
|
1313
|
+
* ```ts
|
|
1314
|
+
* import { Effect } from "effect"
|
|
1315
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1316
|
+
* import * as Push from "@typed/fx/Push"
|
|
1317
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1318
|
+
*
|
|
1319
|
+
* const constructed: Array<number> = []
|
|
1320
|
+
* const finalized: Array<number> = []
|
|
1321
|
+
* const push = Push.make(
|
|
1322
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1323
|
+
* Fx.fromIterable([1, 2, 3])
|
|
1324
|
+
* )
|
|
1325
|
+
* const latestSaved = Push.exhaustLatestMapEffect(push, (id) => {
|
|
1326
|
+
* constructed.push(id)
|
|
1327
|
+
* return Effect.sleep("10 millis").pipe(
|
|
1328
|
+
* Effect.as(id),
|
|
1329
|
+
* Effect.ensuring(Effect.sync(() => finalized.push(id)))
|
|
1330
|
+
* )
|
|
1331
|
+
* })
|
|
1332
|
+
* const program = Fx.collectAll(latestSaved).pipe(
|
|
1333
|
+
* Effect.map((values) => ({ values, constructed, finalized })),
|
|
1334
|
+
* Effect.scoped
|
|
1335
|
+
* )
|
|
1336
|
+
* // Effect.runPromise(program) => { values: [1, 3], constructed: [1, 2, 3], finalized: [1, 3] }
|
|
1337
|
+
* ```
|
|
1338
|
+
*
|
|
1339
|
+
* @since 1.0.0
|
|
1340
|
+
* @category Concurrent output work
|
|
1341
|
+
*/
|
|
341
1342
|
export declare const exhaustLatestMapEffect: {
|
|
342
1343
|
<B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
343
|
-
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R,
|
|
1344
|
+
<A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3 | Scope.Scope>;
|
|
344
1345
|
};
|
|
345
1346
|
/**
|
|
346
1347
|
* Maps over the output (Fx) side of a `Push` with an accumulator: for each emitted value `b`,
|
|
347
1348
|
* applies `f(state, b)` to get `[nextState, emitted]` and emits the second element.
|
|
348
1349
|
* The first element is the initial state; subsequent states are updated by each step.
|
|
1350
|
+
* It emits exactly one `C` per upstream value, in order. Accumulator state is
|
|
1351
|
+
* private to each output subscription; the input Sink is unchanged.
|
|
1352
|
+
*
|
|
1353
|
+
* @remarks
|
|
1354
|
+
* ## Why
|
|
1355
|
+
*
|
|
1356
|
+
* Stateful output projection can derive running totals or protocol state without
|
|
1357
|
+
* moving that state into the bidirectional input boundary.
|
|
1358
|
+
*
|
|
1359
|
+
* ## Ownership and lifetime
|
|
1360
|
+
*
|
|
1361
|
+
* Each run owns its own synchronous accumulator. It is discarded when that run
|
|
1362
|
+
* completes or is interrupted and acquires no Scope or external resource.
|
|
1363
|
+
*
|
|
1364
|
+
* @example
|
|
1365
|
+
* ```ts
|
|
1366
|
+
* import { Effect } from "effect"
|
|
1367
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1368
|
+
* import * as Push from "@typed/fx/Push"
|
|
1369
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1370
|
+
*
|
|
1371
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.fromIterable([1, 2, 3]))
|
|
1372
|
+
* const totals = Push.mapAccum(push, 0, (total, value) => [total + value, total + value] as const)
|
|
1373
|
+
* ```
|
|
349
1374
|
*
|
|
350
1375
|
* @param initial - Initial accumulator state.
|
|
351
1376
|
* @param f - Reducer `(state, value) => [nextState, emitted]`.
|
|
352
1377
|
* @returns A `Push` whose Fx side emits the accumulated/mapped values.
|
|
353
1378
|
* @since 1.0.0
|
|
354
|
-
* @category
|
|
1379
|
+
* @category Stateful outputs
|
|
355
1380
|
*/
|
|
356
1381
|
export declare const mapAccum: {
|
|
357
1382
|
<S, B, C>(initial: S, f: (s: S, b: B) => readonly [S, C]): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2, R2>;
|
|
@@ -360,16 +1385,116 @@ export declare const mapAccum: {
|
|
|
360
1385
|
/**
|
|
361
1386
|
* Maps over the output (Fx) side of a `Push` with an effectful accumulator: for each emitted value `b`,
|
|
362
1387
|
* runs `f(state, b)` to get `[nextState, emitted]` and emits the second element.
|
|
1388
|
+
* The adapter does not serialize callbacks. Calling `onSuccess` invokes `f`
|
|
1389
|
+
* immediately with the current seed and constructs its Effect; overlapping calls
|
|
1390
|
+
* can therefore observe the same seed. Successful completion commits the returned
|
|
1391
|
+
* seed and emits in completion order, so later completion may overwrite newer
|
|
1392
|
+
* state. Reducer failure is sent to the output Sink, emits nothing, restores that
|
|
1393
|
+
* call's previous seed, and completes normally so a continuing producer can send
|
|
1394
|
+
* later values. The input Sink is unchanged.
|
|
1395
|
+
*
|
|
1396
|
+
* @remarks
|
|
1397
|
+
* ## Why
|
|
1398
|
+
*
|
|
1399
|
+
* Use an effectful accumulator when each transition needs services or can fail,
|
|
1400
|
+
* while keeping state local to observation rather than global application state.
|
|
1401
|
+
*
|
|
1402
|
+
* ## Ownership and lifetime
|
|
1403
|
+
*
|
|
1404
|
+
* Each output run owns one mutable seed, but concurrent producer callbacks may
|
|
1405
|
+
* race over it; callers needing serialized state transitions must serialize the
|
|
1406
|
+
* upstream deliveries. Each callback fiber runs and interrupts its own reducer
|
|
1407
|
+
* Effect. `E3` and `R3` join the output channels. State is discarded when the
|
|
1408
|
+
* subscription ends.
|
|
1409
|
+
*
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```ts
|
|
1412
|
+
* import { Effect } from "effect"
|
|
1413
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1414
|
+
* import * as Push from "@typed/fx/Push"
|
|
1415
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1416
|
+
*
|
|
1417
|
+
* const concurrent = Fx.make<number>((sink) =>
|
|
1418
|
+
* Effect.all([sink.onSuccess(1), sink.onSuccess(2)], {
|
|
1419
|
+
* concurrency: "unbounded",
|
|
1420
|
+
* discard: true
|
|
1421
|
+
* })
|
|
1422
|
+
* )
|
|
1423
|
+
* const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), concurrent)
|
|
1424
|
+
* const totals = Push.mapAccumEffect(push, 0, (seed, value) =>
|
|
1425
|
+
* Effect.sleep(value === 1 ? "20 millis" : "1 millis").pipe(
|
|
1426
|
+
* Effect.as([seed + value, seed + value] as const)
|
|
1427
|
+
* )
|
|
1428
|
+
* )
|
|
1429
|
+
* const program = Fx.collectAll(totals).pipe(Effect.scoped)
|
|
1430
|
+
* // Both reducers see seed 0; Effect.runPromise(program) resolves to [2, 1].
|
|
1431
|
+
*
|
|
1432
|
+
* const values: Array<number> = []
|
|
1433
|
+
* let failures = 0
|
|
1434
|
+
* const sequential = Push.make(
|
|
1435
|
+
* Sink.make(() => Effect.void, (_: string) => Effect.void),
|
|
1436
|
+
* Fx.fromIterable([1, 2, 3])
|
|
1437
|
+
* )
|
|
1438
|
+
* const continued = Push.mapAccumEffect(sequential, 0, (seed, value) =>
|
|
1439
|
+
* value === 2
|
|
1440
|
+
* ? Effect.fail("rejected" as const)
|
|
1441
|
+
* : Effect.succeed([seed + value, seed + value] as const)
|
|
1442
|
+
* )
|
|
1443
|
+
* const recovery = continued.run(Sink.make(
|
|
1444
|
+
* () => Effect.sync(() => { failures += 1 }),
|
|
1445
|
+
* (value) => Effect.sync(() => values.push(value))
|
|
1446
|
+
* ))
|
|
1447
|
+
* // Effect.runPromise(recovery) leaves values [1, 4] and failures 1.
|
|
1448
|
+
* ```
|
|
363
1449
|
*
|
|
364
1450
|
* @param initial - Initial accumulator state.
|
|
365
1451
|
* @param f - Effectful reducer `(state, value) => Effect<[nextState, emitted]>`.
|
|
366
1452
|
* @returns A `Push` whose Fx side emits the accumulated/mapped values.
|
|
367
1453
|
* @since 1.0.0
|
|
368
|
-
* @category
|
|
1454
|
+
* @category Stateful outputs
|
|
369
1455
|
*/
|
|
370
1456
|
export declare const mapAccumEffect: {
|
|
371
1457
|
<S, B, C, E3, R3>(initial: S, f: (s: S, b: B) => Effect.Effect<readonly [S, C], E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3>;
|
|
372
1458
|
<A, E, R, B, E2, R2, S, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, initial: S, f: (s: S, b: B) => Effect.Effect<readonly [S, C], E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3>;
|
|
373
1459
|
};
|
|
1460
|
+
/**
|
|
1461
|
+
* Defines a named Effect service whose value is a `Push`.
|
|
1462
|
+
*
|
|
1463
|
+
* The returned class exposes `onSuccess`, `onFailure`, and `run` as Effects that
|
|
1464
|
+
* first resolve the service from Context. `make` captures the Sink construction
|
|
1465
|
+
* context and combines it with each output subscriber's context; it does not start
|
|
1466
|
+
* the Fx or send an input while building the Layer.
|
|
1467
|
+
*
|
|
1468
|
+
* @remarks
|
|
1469
|
+
* ## Why
|
|
1470
|
+
*
|
|
1471
|
+
* A service gives a bidirectional application capability one stable identity, so
|
|
1472
|
+
* producers and observers can depend on it through ordinary Effect requirements.
|
|
1473
|
+
*
|
|
1474
|
+
* ## Ownership and lifetime
|
|
1475
|
+
*
|
|
1476
|
+
* The returned Layer owns service installation and captures non-Scope services
|
|
1477
|
+
* needed by both sides. Output runs retain the caller's Scope and interruption;
|
|
1478
|
+
* input acknowledgment Effects run in their caller. Layer release drops the
|
|
1479
|
+
* service but does not invent cleanup beyond the supplied Sink and Fx.
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```ts
|
|
1483
|
+
* import { Effect, Layer } from "effect"
|
|
1484
|
+
* import * as Fx from "@typed/fx/Fx"
|
|
1485
|
+
* import * as Push from "@typed/fx/Push"
|
|
1486
|
+
* import * as Sink from "@typed/fx/Sink"
|
|
1487
|
+
*
|
|
1488
|
+
* class Messages extends Push.Service<Messages, string, never, string>()("Messages") {}
|
|
1489
|
+
* const MessagesLive = Messages.make(
|
|
1490
|
+
* Sink.make(() => Effect.void, (message) => Effect.log(message)),
|
|
1491
|
+
* Fx.succeed("ready")
|
|
1492
|
+
* )
|
|
1493
|
+
* const send = Messages.onSuccess("hello").pipe(Effect.provide(MessagesLive))
|
|
1494
|
+
* ```
|
|
1495
|
+
*
|
|
1496
|
+
* @since 1.0.0
|
|
1497
|
+
* @category Push services
|
|
1498
|
+
*/
|
|
374
1499
|
export declare function Service<Self, A, E = never, B = never, E2 = never>(): <const Id extends string>(id: Id) => Push.Class<Self, Id, A, E, B, E2>;
|
|
375
1500
|
//# sourceMappingURL=Push.d.ts.map
|