@typed/fx 1.27.3 → 1.28.0
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/dist/cjs/AsyncData.js +1 -1
- package/dist/cjs/AsyncData.js.map +1 -1
- package/dist/cjs/Emitter.js +3 -3
- package/dist/cjs/Emitter.js.map +1 -1
- package/dist/cjs/Form.js +15 -15
- package/dist/cjs/Form.js.map +1 -1
- package/dist/cjs/FormEntry.js +3 -3
- package/dist/cjs/FormEntry.js.map +1 -1
- package/dist/cjs/Fx.js +11 -9
- package/dist/cjs/Fx.js.map +1 -1
- package/dist/cjs/Idle.js +8 -8
- package/dist/cjs/Idle.js.map +1 -1
- package/dist/cjs/Match.js +17 -17
- package/dist/cjs/Match.js.map +1 -1
- package/dist/cjs/Pull.js +3 -3
- package/dist/cjs/Pull.js.map +1 -1
- package/dist/cjs/Push.js +1 -1
- package/dist/cjs/Push.js.map +1 -1
- package/dist/cjs/RefArray.js +2 -2
- package/dist/cjs/RefArray.js.map +1 -1
- package/dist/cjs/RefChunk.js +1 -1
- package/dist/cjs/RefChunk.js.map +1 -1
- package/dist/cjs/RefHashMap.js +1 -1
- package/dist/cjs/RefHashMap.js.map +1 -1
- package/dist/cjs/RefHashSet.js +1 -1
- package/dist/cjs/RefHashSet.js.map +1 -1
- package/dist/cjs/RefSubject.js +150 -75
- package/dist/cjs/RefSubject.js.map +1 -1
- package/dist/cjs/Sink.js +14 -14
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +1 -1
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Subject.js +27 -22
- package/dist/cjs/Subject.js.map +1 -1
- package/dist/cjs/Typeclass.js +1 -1
- package/dist/cjs/Typeclass.js.map +1 -1
- package/dist/cjs/Versioned.js +4 -4
- package/dist/cjs/Versioned.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/DeferredRef.js +14 -11
- package/dist/cjs/internal/DeferredRef.js.map +1 -1
- package/dist/cjs/internal/core.js +71 -42
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/diff.js +1 -1
- package/dist/cjs/internal/diff.js.map +1 -1
- package/dist/cjs/internal/effect-loop-operator.js +1 -1
- package/dist/cjs/internal/effect-loop-operator.js.map +1 -1
- package/dist/cjs/internal/effect-operator.js +3 -3
- package/dist/cjs/internal/effect-operator.js.map +1 -1
- package/dist/cjs/internal/effect-producer.js +3 -3
- package/dist/cjs/internal/effect-producer.js.map +1 -1
- package/dist/cjs/internal/helpers.js +63 -42
- package/dist/cjs/internal/helpers.js.map +1 -1
- package/dist/cjs/internal/keyed.js +34 -26
- package/dist/cjs/internal/keyed.js.map +1 -1
- package/dist/cjs/internal/loop-operator.js +1 -1
- package/dist/cjs/internal/loop-operator.js.map +1 -1
- package/dist/cjs/internal/operator.js +1 -1
- package/dist/cjs/internal/operator.js.map +1 -1
- package/dist/cjs/internal/protos.js +1 -1
- package/dist/cjs/internal/protos.js.map +1 -1
- package/dist/cjs/internal/provide.js +1 -1
- package/dist/cjs/internal/provide.js.map +1 -1
- package/dist/cjs/internal/share.js +8 -13
- package/dist/cjs/internal/share.js.map +1 -1
- package/dist/cjs/internal/sync-operator.js +4 -4
- package/dist/cjs/internal/sync-operator.js.map +1 -1
- package/dist/cjs/internal/sync-producer.js +27 -23
- package/dist/cjs/internal/sync-producer.js.map +1 -1
- package/dist/cjs/internal/withKey.js +7 -7
- package/dist/cjs/internal/withKey.js.map +1 -1
- package/dist/dts/AsyncData.d.ts +2 -2
- package/dist/dts/AsyncData.d.ts.map +1 -1
- package/dist/dts/Emitter.d.ts +1 -1
- package/dist/dts/Emitter.d.ts.map +1 -1
- package/dist/dts/Fx.d.ts +39 -13
- package/dist/dts/Fx.d.ts.map +1 -1
- package/dist/dts/Idle.d.ts.map +1 -1
- package/dist/dts/Match.d.ts +1 -1
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/Push.d.ts +4 -1
- package/dist/dts/Push.d.ts.map +1 -1
- package/dist/dts/RefArray.d.ts +1 -2
- package/dist/dts/RefArray.d.ts.map +1 -1
- package/dist/dts/RefChunk.d.ts.map +1 -1
- package/dist/dts/RefHashMap.d.ts +1 -1
- package/dist/dts/RefHashMap.d.ts.map +1 -1
- package/dist/dts/RefHashSet.d.ts.map +1 -1
- package/dist/dts/RefSubject.d.ts +64 -3
- package/dist/dts/RefSubject.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +2 -1
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Subject.d.ts +2 -1
- package/dist/dts/Subject.d.ts.map +1 -1
- package/dist/dts/Versioned.d.ts +3 -1
- package/dist/dts/Versioned.d.ts.map +1 -1
- package/dist/dts/internal/DeferredRef.d.ts +6 -4
- package/dist/dts/internal/DeferredRef.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts +25 -12
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/diff.d.ts +1 -1
- package/dist/dts/internal/diff.d.ts.map +1 -1
- package/dist/dts/internal/effect-operator.d.ts.map +1 -1
- package/dist/dts/internal/helpers.d.ts +8 -6
- package/dist/dts/internal/helpers.d.ts.map +1 -1
- package/dist/dts/internal/keyed.d.ts +2 -2
- package/dist/dts/internal/keyed.d.ts.map +1 -1
- package/dist/dts/internal/loop-operator.d.ts +1 -1
- package/dist/dts/internal/loop-operator.d.ts.map +1 -1
- package/dist/dts/internal/protos.d.ts +1 -1
- package/dist/dts/internal/protos.d.ts.map +1 -1
- package/dist/dts/internal/provide.d.ts.map +1 -1
- package/dist/dts/internal/share.d.ts +1 -1
- package/dist/dts/internal/share.d.ts.map +1 -1
- package/dist/dts/internal/strategies.d.ts.map +1 -1
- package/dist/dts/internal/sync-operator.d.ts.map +1 -1
- package/dist/dts/internal/sync-producer.d.ts +4 -4
- package/dist/dts/internal/sync-producer.d.ts.map +1 -1
- package/dist/esm/Emitter.js +1 -1
- package/dist/esm/Emitter.js.map +1 -1
- package/dist/esm/Form.js +14 -14
- package/dist/esm/Form.js.map +1 -1
- package/dist/esm/FormEntry.js +2 -2
- package/dist/esm/FormEntry.js.map +1 -1
- package/dist/esm/Fx.js +16 -5
- package/dist/esm/Fx.js.map +1 -1
- package/dist/esm/Idle.js +7 -7
- package/dist/esm/Idle.js.map +1 -1
- package/dist/esm/Match.js +17 -17
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Pull.js +2 -2
- package/dist/esm/Push.js.map +1 -1
- package/dist/esm/RefArray.js +1 -1
- package/dist/esm/RefArray.js.map +1 -1
- package/dist/esm/RefHashMap.js.map +1 -1
- package/dist/esm/RefSubject.js +140 -59
- package/dist/esm/RefSubject.js.map +1 -1
- package/dist/esm/Sink.js +13 -13
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Subject.js +29 -20
- package/dist/esm/Subject.js.map +1 -1
- package/dist/esm/Versioned.js +1 -1
- package/dist/esm/Versioned.js.map +1 -1
- package/dist/esm/internal/DeferredRef.js +13 -10
- package/dist/esm/internal/DeferredRef.js.map +1 -1
- package/dist/esm/internal/core.js +70 -37
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/diff.js.map +1 -1
- package/dist/esm/internal/effect-operator.js +2 -2
- package/dist/esm/internal/effect-producer.js +1 -1
- package/dist/esm/internal/helpers.js +62 -39
- package/dist/esm/internal/helpers.js.map +1 -1
- package/dist/esm/internal/keyed.js +26 -17
- package/dist/esm/internal/keyed.js.map +1 -1
- package/dist/esm/internal/share.js +7 -12
- package/dist/esm/internal/share.js.map +1 -1
- package/dist/esm/internal/sync-operator.js +3 -3
- package/dist/esm/internal/sync-operator.js.map +1 -1
- package/dist/esm/internal/sync-producer.js +7 -5
- package/dist/esm/internal/sync-producer.js.map +1 -1
- package/dist/esm/internal/withKey.js +6 -6
- package/dist/esm/internal/withKey.js.map +1 -1
- package/package.json +8 -7
- package/src/Emitter.ts +2 -1
- package/src/Form.ts +22 -30
- package/src/FormEntry.ts +2 -2
- package/src/Fx.ts +54 -36
- package/src/Idle.ts +7 -7
- package/src/Match.ts +24 -26
- package/src/Pull.ts +2 -2
- package/src/Push.ts +4 -1
- package/src/RefArray.ts +1 -1
- package/src/RefHashMap.ts +1 -1
- package/src/RefSubject.ts +262 -98
- package/src/Sink.ts +15 -14
- package/src/Subject.ts +55 -39
- package/src/Versioned.ts +4 -2
- package/src/internal/DeferredRef.ts +21 -11
- package/src/internal/core.ts +92 -61
- package/src/internal/diff.ts +1 -1
- package/src/internal/effect-operator.ts +2 -2
- package/src/internal/effect-producer.ts +3 -3
- package/src/internal/helpers.ts +89 -42
- package/src/internal/keyed.ts +47 -42
- package/src/internal/loop-operator.ts +1 -1
- package/src/internal/protos.ts +1 -1
- package/src/internal/share.ts +11 -26
- package/src/internal/sync-operator.ts +3 -3
- package/src/internal/sync-producer.ts +7 -5
- package/src/internal/withKey.ts +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefHashSet.js","names":["_Function","require","HashSet","_interopRequireWildcard","RefSubject","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","
|
|
1
|
+
{"version":3,"file":"RefHashSet.js","names":["_Function","require","HashSet","_interopRequireWildcard","RefSubject","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","make","initial","tagged","exports","add","dual","ref","value","update","appendAll","mutate","filterValues","predicate","map","filter","size","mapValues","f","partition","reduce","b"],"sources":["../../src/RefHashSet.ts"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
package/dist/cjs/RefSubject.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.isFiltered = isFiltered;
|
|
|
18
18
|
exports.isRefSubject = isRefSubject;
|
|
19
19
|
exports.modifyEffect = exports.modify = exports.mapEffect = exports.map = exports.make = void 0;
|
|
20
20
|
exports.of = of;
|
|
21
|
-
exports.provide = void 0;
|
|
21
|
+
exports.proxy = exports.provide = void 0;
|
|
22
22
|
exports.delete = exports.reset = reset;
|
|
23
23
|
exports.set = exports.runUpdates = void 0;
|
|
24
24
|
exports.skipRepeats = skipRepeats;
|
|
@@ -31,33 +31,34 @@ exports.transformOrFail = transformOrFail;
|
|
|
31
31
|
exports.tuple = tuple;
|
|
32
32
|
exports.unsafeGetExit = exports.unsafeGet = void 0;
|
|
33
33
|
exports.unsafeMake = unsafeMake;
|
|
34
|
-
exports.updateEffect = exports.update = void 0;
|
|
34
|
+
exports.withSpan = exports.when = exports.updateEffect = exports.update = void 0;
|
|
35
35
|
var C = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/context"));
|
|
36
|
-
var
|
|
36
|
+
var Array = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Array"));
|
|
37
37
|
var Boolean = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Boolean"));
|
|
38
38
|
var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Cause"));
|
|
39
39
|
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Effect"));
|
|
40
|
-
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Equal"));
|
|
41
40
|
var ExecutionStrategy = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/ExecutionStrategy"));
|
|
42
41
|
var Exit = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Exit"));
|
|
42
|
+
var Fiber = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Fiber"));
|
|
43
43
|
var _Function = /*#__PURE__*/require("effect/Function");
|
|
44
44
|
var Layer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Layer"));
|
|
45
|
+
var MutableRef = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/MutableRef"));
|
|
45
46
|
var _Number = /*#__PURE__*/require("effect/Number");
|
|
46
47
|
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Option"));
|
|
47
|
-
var ReadonlyArray = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/ReadonlyArray"));
|
|
48
48
|
var Scope = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Scope"));
|
|
49
|
-
var
|
|
49
|
+
var Unify = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Unify"));
|
|
50
|
+
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/core.js"));
|
|
50
51
|
var DeferredRef = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/DeferredRef.js"));
|
|
51
52
|
var _helpers = /*#__PURE__*/require("./internal/helpers.js");
|
|
52
53
|
var _protos = /*#__PURE__*/require("./internal/protos.js");
|
|
53
54
|
var _provide = /*#__PURE__*/require("./internal/provide.js");
|
|
54
|
-
var
|
|
55
|
+
var _share = /*#__PURE__*/require("./internal/share.js");
|
|
55
56
|
var Sink = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Sink.js"));
|
|
56
57
|
var Subject = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Subject.js"));
|
|
57
58
|
var _TypeId = /*#__PURE__*/require("./TypeId.js");
|
|
58
59
|
var Versioned = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Versioned.js"));
|
|
59
60
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
60
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
61
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
61
62
|
/**
|
|
62
63
|
* A RefSubject is a Subject that can be used to read and write a value.
|
|
63
64
|
* @since 1.20.0
|
|
@@ -66,6 +67,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
66
67
|
const UNBOUNDED = {
|
|
67
68
|
concurrency: "unbounded"
|
|
68
69
|
};
|
|
70
|
+
// TODO: Kind of a Hack, but I don't really want to pollute the public API with this. What should we do with this?
|
|
71
|
+
const CURRENT_ENVIRONMENT_TAG = /*#__PURE__*/C.Tagged("@typed/environment/CurrentEnvironment");
|
|
72
|
+
const checkIsDOM = ctx => C.getOption(ctx, CURRENT_ENVIRONMENT_TAG).pipe(Option.map(s => s === "dom" || s === "test:dom"),
|
|
73
|
+
// Default behavior should allow multiple updates via Fx interface
|
|
74
|
+
Option.getOrElse(() => true));
|
|
69
75
|
/**
|
|
70
76
|
* @since 1.20.0
|
|
71
77
|
*/
|
|
@@ -76,7 +82,7 @@ function fromEffect(effect, options) {
|
|
|
76
82
|
* @since 1.20.0
|
|
77
83
|
*/
|
|
78
84
|
function fromFx(fx, options) {
|
|
79
|
-
return DeferredRef.make((0, _helpers.getExitEquivalence)(options?.eq ??
|
|
85
|
+
return DeferredRef.make((0, _helpers.getExitEquivalence)(options?.eq ?? internal.deepEquals)).pipe(Effect.bindTo("deferredRef"), Effect.bind("core", ({
|
|
80
86
|
deferredRef
|
|
81
87
|
}) => makeCore(deferredRef, options)), Effect.tap(({
|
|
82
88
|
core,
|
|
@@ -89,7 +95,7 @@ function fromFx(fx, options) {
|
|
|
89
95
|
* @since 1.20.0
|
|
90
96
|
*/
|
|
91
97
|
function fromRefSubject(ref, options) {
|
|
92
|
-
return DeferredRef.make((0, _helpers.getExitEquivalence)(options?.eq ??
|
|
98
|
+
return DeferredRef.make((0, _helpers.getExitEquivalence)(options?.eq ?? internal.deepEquals)).pipe(Effect.bindTo("deferredRef"), Effect.bind("core", ({
|
|
93
99
|
deferredRef
|
|
94
100
|
}) => makeCore(deferredRef, options)), Effect.tap(({
|
|
95
101
|
core,
|
|
@@ -133,13 +139,17 @@ function unsafeMake(params) {
|
|
|
133
139
|
} = params;
|
|
134
140
|
return Effect.flatMap(Effect.runtime(), runtime => {
|
|
135
141
|
const core = unsafeMakeCore(initial, id, runtime, scope, options);
|
|
142
|
+
const current = MutableRef.get(core.deferredRef.current);
|
|
136
143
|
// Sometimes we might be instantiating directly from a known value
|
|
137
144
|
// Here we seed the value and ensure the subject has it as well for re-broadcasting
|
|
138
|
-
if ("initialValue" in params) {
|
|
145
|
+
if ("initialValue" in params && Option.isNone(current)) {
|
|
139
146
|
core.deferredRef.done(Exit.succeed(params.initialValue));
|
|
140
147
|
return Effect.map(core.subject.onSuccess(params.initialValue), () => new RefSubjectImpl(core));
|
|
148
|
+
} else if (Option.isSome(current)) {
|
|
149
|
+
return Effect.map(Effect.matchCauseEffect(current.value, core.subject), () => new RefSubjectImpl(core));
|
|
150
|
+
} else {
|
|
151
|
+
return Effect.succeed(new RefSubjectImpl(core));
|
|
141
152
|
}
|
|
142
|
-
return Effect.succeed(new RefSubjectImpl(core));
|
|
143
153
|
});
|
|
144
154
|
}
|
|
145
155
|
class RefSubjectImpl extends _protos.FxEffectBase {
|
|
@@ -170,7 +180,7 @@ class RefSubjectImpl extends _protos.FxEffectBase {
|
|
|
170
180
|
runUpdates(run) {
|
|
171
181
|
return this.core.semaphore.withPermits(1)(run(this.getSetDelete));
|
|
172
182
|
}
|
|
173
|
-
unsafeGet = () => Option.getOrThrowWith(this.core.deferredRef.current, () => new Cause.NoSuchElementException());
|
|
183
|
+
unsafeGet = () => Option.getOrThrowWith(MutableRef.get(this.core.deferredRef.current), () => new Cause.NoSuchElementException());
|
|
174
184
|
onSuccess(value) {
|
|
175
185
|
return setCore(this.core, value);
|
|
176
186
|
}
|
|
@@ -243,9 +253,9 @@ const runUpdates = exports.runUpdates = /*#__PURE__*/(0, _Function.dual)(isRefSu
|
|
|
243
253
|
if (!options) {
|
|
244
254
|
return ref.runUpdates(f);
|
|
245
255
|
} else if (options.value === "initial") {
|
|
246
|
-
return ref.runUpdates(ref => Effect.uninterruptibleMask(restore => Effect.flatMap(ref.get, initial => f(ref).pipe(restore, Effect.tapErrorCause(
|
|
256
|
+
return ref.runUpdates(ref => Effect.uninterruptibleMask(restore => Effect.flatMap(ref.get, initial => f(ref).pipe(restore, Effect.tapErrorCause(Unify.unify(cause => Cause.isInterruptedOnly(cause) ? options.onInterrupt(initial) : Effect.void))))));
|
|
247
257
|
} else {
|
|
248
|
-
return ref.runUpdates(ref => Effect.uninterruptibleMask(restore => f(ref).pipe(restore, Effect.tapErrorCause(
|
|
258
|
+
return ref.runUpdates(ref => Effect.uninterruptibleMask(restore => f(ref).pipe(restore, Effect.tapErrorCause(Unify.unify(cause => Cause.isInterruptedOnly(cause) ? Effect.flatMap(ref.get, options.onInterrupt) : Effect.void)))));
|
|
249
259
|
}
|
|
250
260
|
});
|
|
251
261
|
class RefSubjectCore {
|
|
@@ -269,22 +279,34 @@ function makeCore(initial, options) {
|
|
|
269
279
|
return Effect.runtime().pipe(Effect.bindTo("runtime"), Effect.let("executionStrategy", () => options?.executionStrategy ?? ExecutionStrategy.parallel), Effect.bind("scope", ({
|
|
270
280
|
executionStrategy,
|
|
271
281
|
runtime
|
|
272
|
-
}) => Scope.fork(C.get(runtime.context, Scope.Scope), executionStrategy)), Effect.bind("
|
|
273
|
-
|
|
274
|
-
subject
|
|
275
|
-
}) => Scope.addFinalizer(scope, subject.interrupt)), Effect.map(({
|
|
276
|
-
deferredRef,
|
|
282
|
+
}) => Scope.fork(C.get(runtime.context, Scope.Scope), executionStrategy)), Effect.bind("id", () => Effect.fiberId), Effect.map(({
|
|
283
|
+
id,
|
|
277
284
|
runtime,
|
|
278
|
-
scope
|
|
279
|
-
|
|
280
|
-
}) => new RefSubjectCore(initial, subject, runtime, scope, deferredRef, Effect.unsafeMakeSemaphore(1))));
|
|
285
|
+
scope
|
|
286
|
+
}) => unsafeMakeCore(initial, id, runtime, scope, options)), Effect.tap(core => Scope.addFinalizer(core.scope, Effect.provide(core.subject.interrupt, core.runtime.context))));
|
|
281
287
|
}
|
|
282
288
|
function unsafeMakeCore(initial, id, runtime, scope, options) {
|
|
283
|
-
|
|
289
|
+
const subject = new Subject.HoldSubjectImpl();
|
|
290
|
+
const core = new RefSubjectCore(initial, subject, runtime, scope, DeferredRef.unsafeMake(id, (0, _helpers.getExitEquivalence)(options?.eq ?? internal.deepEquals), subject.lastValue), Effect.unsafeMakeSemaphore(1));
|
|
291
|
+
const onSuccess = a => core.deferredRef.done(Exit.succeed(a));
|
|
292
|
+
const onCause = cause => core.deferredRef.done(Exit.failCause(cause));
|
|
293
|
+
const onError = e => onCause(Cause.fail(e));
|
|
294
|
+
// Initialize the core with the initial value if it is synchronous
|
|
295
|
+
(0, _helpers.matchEffectPrimitive)(initial, {
|
|
296
|
+
Success: onSuccess,
|
|
297
|
+
Failure: onCause,
|
|
298
|
+
Some: onSuccess,
|
|
299
|
+
None: onError,
|
|
300
|
+
Left: onError,
|
|
301
|
+
Right: onSuccess,
|
|
302
|
+
Sync: f => onSuccess(f()),
|
|
303
|
+
Otherwise: () => false
|
|
304
|
+
});
|
|
305
|
+
return core;
|
|
284
306
|
}
|
|
285
307
|
function getOrInitializeCore(core, lockInitialize) {
|
|
286
308
|
return Effect.suspend(() => {
|
|
287
|
-
if (core._fiber === undefined && Option.isNone(core.deferredRef.current)) {
|
|
309
|
+
if (core._fiber === undefined && Option.isNone(MutableRef.get(core.deferredRef.current))) {
|
|
288
310
|
return initializeCoreAndTap(core, lockInitialize);
|
|
289
311
|
} else {
|
|
290
312
|
return core.deferredRef;
|
|
@@ -296,16 +318,16 @@ function initializeCoreEffect(core, lock) {
|
|
|
296
318
|
core._fiber = undefined;
|
|
297
319
|
core.deferredRef.done(exit);
|
|
298
320
|
}));
|
|
299
|
-
return Effect.flatMap(Effect.forkIn(lock
|
|
321
|
+
return Effect.flatMap(Effect.forkIn(lock ? core.semaphore.withPermits(1)(initialize) : initialize, core.scope), fiber => Effect.sync(() => core._fiber = fiber));
|
|
300
322
|
}
|
|
301
323
|
function initializeCore(core, lock) {
|
|
302
324
|
const onSuccess = a => {
|
|
303
325
|
core.deferredRef.done(Exit.succeed(a));
|
|
304
|
-
return Effect.succeed(
|
|
326
|
+
return Effect.succeed(Fiber.succeed(a));
|
|
305
327
|
};
|
|
306
328
|
const onCause = cause => {
|
|
307
329
|
core.deferredRef.done(Exit.failCause(cause));
|
|
308
|
-
return Effect.succeed(
|
|
330
|
+
return Effect.succeed(Fiber.failCause(cause));
|
|
309
331
|
};
|
|
310
332
|
const onError = e => onCause(Cause.fail(e));
|
|
311
333
|
return (0, _helpers.matchEffectPrimitive)(core.initial, {
|
|
@@ -315,7 +337,7 @@ function initializeCore(core, lock) {
|
|
|
315
337
|
None: onError,
|
|
316
338
|
Left: onError,
|
|
317
339
|
Right: onSuccess,
|
|
318
|
-
Sync: f => onSuccess(f()),
|
|
340
|
+
Sync: f => Effect.suspend(() => onSuccess(f())),
|
|
319
341
|
Otherwise: () => initializeCoreEffect(core, lock)
|
|
320
342
|
});
|
|
321
343
|
}
|
|
@@ -340,7 +362,7 @@ function onFailureCore(core, cause) {
|
|
|
340
362
|
if (core.deferredRef.done(exit)) {
|
|
341
363
|
return sendEvent(core, exit);
|
|
342
364
|
} else {
|
|
343
|
-
return Effect.
|
|
365
|
+
return Effect.void;
|
|
344
366
|
}
|
|
345
367
|
});
|
|
346
368
|
}
|
|
@@ -348,7 +370,7 @@ function interruptCore(core) {
|
|
|
348
370
|
return Effect.fiberIdWith(id => {
|
|
349
371
|
core.deferredRef.reset();
|
|
350
372
|
const closeScope = Scope.close(core.scope, Exit.interrupt(id));
|
|
351
|
-
const interruptFiber = core._fiber ?
|
|
373
|
+
const interruptFiber = core._fiber ? Fiber.interrupt(core._fiber) : Effect.void;
|
|
352
374
|
const interruptSubject = core.subject.interrupt;
|
|
353
375
|
return Effect.all([closeScope, interruptFiber, interruptSubject], {
|
|
354
376
|
discard: true
|
|
@@ -357,12 +379,12 @@ function interruptCore(core) {
|
|
|
357
379
|
}
|
|
358
380
|
function deleteCore(core) {
|
|
359
381
|
return Effect.suspend(() => {
|
|
360
|
-
const current = core.deferredRef.current;
|
|
382
|
+
const current = MutableRef.get(core.deferredRef.current);
|
|
361
383
|
core.deferredRef.reset();
|
|
362
384
|
if (Option.isNone(current)) {
|
|
363
385
|
return Effect.succeed(Option.none());
|
|
364
386
|
}
|
|
365
|
-
return core.subject.subscriberCount.pipe(Effect.provide(core.runtime.context), Effect.flatMap(count => count > 0 && !core._fiber ? initializeCore(core, false) : Effect.
|
|
387
|
+
return core.subject.subscriberCount.pipe(Effect.provide(core.runtime.context), Effect.flatMap(count => count > 0 && !core._fiber ? initializeCore(core, false) : Effect.void), Effect.zipRight(Effect.asSome(current.value)));
|
|
366
388
|
});
|
|
367
389
|
}
|
|
368
390
|
function tapEventCore(core, effect) {
|
|
@@ -421,10 +443,20 @@ class ComputedImpl extends Versioned.VersionedTransform {
|
|
|
421
443
|
input;
|
|
422
444
|
f;
|
|
423
445
|
[_TypeId.ComputedTypeId] = _TypeId.ComputedTypeId;
|
|
446
|
+
_computed;
|
|
424
447
|
constructor(input, f) {
|
|
425
|
-
super(input, fx =>
|
|
448
|
+
super(input, fx => internal.mapEffect(fx, f), Effect.flatMap(f));
|
|
426
449
|
this.input = input;
|
|
427
450
|
this.f = f;
|
|
451
|
+
this._computed = (0, _share.hold)(internal.fromFxEffect(Effect.contextWith(ctx => {
|
|
452
|
+
if (checkIsDOM(ctx)) {
|
|
453
|
+
return internal.fromEffect(input).pipe(_ => internal.continueWith(_, () => input), internal.skipRepeats, _ => internal.mapEffect(_, f), internal.skipRepeats);
|
|
454
|
+
}
|
|
455
|
+
return internal.fromEffect(Effect.flatMap(input, f));
|
|
456
|
+
})));
|
|
457
|
+
}
|
|
458
|
+
run(sink) {
|
|
459
|
+
return this._computed.run(sink);
|
|
428
460
|
}
|
|
429
461
|
unsafeGet = () => Option.getOrThrowWith(this._currentValue, () => new Cause.NoSuchElementException());
|
|
430
462
|
static make(input, f) {
|
|
@@ -435,10 +467,17 @@ class FilteredImpl extends Versioned.VersionedTransform {
|
|
|
435
467
|
input;
|
|
436
468
|
f;
|
|
437
469
|
[_TypeId.FilteredTypeId] = _TypeId.FilteredTypeId;
|
|
470
|
+
_filtered;
|
|
438
471
|
constructor(input, f) {
|
|
439
|
-
super(input, fx =>
|
|
472
|
+
super(input, fx => internal.filterMapEffect(fx, f), effect => Effect.flatten(Effect.flatMap(effect, f)));
|
|
440
473
|
this.input = input;
|
|
441
474
|
this.f = f;
|
|
475
|
+
this._filtered = (0, _share.hold)(internal.fromFxEffect(Effect.contextWith(ctx => {
|
|
476
|
+
if (checkIsDOM(ctx)) {
|
|
477
|
+
return internal.fromEffect(input).pipe(_ => internal.continueWith(_, () => input), internal.skipRepeats, _ => internal.filterMapEffect(_, f), internal.skipRepeats);
|
|
478
|
+
}
|
|
479
|
+
return Effect.flatMap(input, f).pipe(internal.fromEffect, _ => internal.filterMap(_, _Function.identity));
|
|
480
|
+
})));
|
|
442
481
|
}
|
|
443
482
|
static make(input, f) {
|
|
444
483
|
return new FilteredImpl(input, f);
|
|
@@ -446,13 +485,16 @@ class FilteredImpl extends Versioned.VersionedTransform {
|
|
|
446
485
|
asComputed() {
|
|
447
486
|
return ComputedImpl.make(this.input, this.f);
|
|
448
487
|
}
|
|
488
|
+
run(sink) {
|
|
489
|
+
return this._filtered.run(sink);
|
|
490
|
+
}
|
|
449
491
|
unsafeGet = () => Option.getOrThrowWith(this._currentValue, () => new Cause.NoSuchElementException());
|
|
450
492
|
}
|
|
451
493
|
/**
|
|
452
494
|
* @since 1.20.0
|
|
453
495
|
*/
|
|
454
496
|
const skipRepeatsWith = exports.skipRepeatsWith = /*#__PURE__*/(0, _Function.dual)(2, function skipRepeatsWith(ref, eq) {
|
|
455
|
-
const versioned = Versioned.transform(ref, fx =>
|
|
497
|
+
const versioned = Versioned.transform(ref, fx => internal.skipRepeatsWith(fx, eq), _Function.identity);
|
|
456
498
|
if (_TypeId.FilteredTypeId in ref) {
|
|
457
499
|
return FilteredImpl.make(versioned, Effect.succeedSome);
|
|
458
500
|
} else {
|
|
@@ -460,7 +502,7 @@ const skipRepeatsWith = exports.skipRepeatsWith = /*#__PURE__*/(0, _Function.dua
|
|
|
460
502
|
}
|
|
461
503
|
});
|
|
462
504
|
function skipRepeats(ref) {
|
|
463
|
-
return skipRepeatsWith(ref,
|
|
505
|
+
return skipRepeatsWith(ref, internal.deepEquals);
|
|
464
506
|
}
|
|
465
507
|
/**
|
|
466
508
|
* @since 1.20.0
|
|
@@ -537,7 +579,7 @@ class RefSubjectTransformEffect extends _protos.FxEffectBase {
|
|
|
537
579
|
this.subject = new Subject.HoldSubjectImpl();
|
|
538
580
|
}
|
|
539
581
|
run(sink) {
|
|
540
|
-
return
|
|
582
|
+
return internal.skipRepeats(internal.merge(internal.tapEffect(internal.mapEffect(this.ref, this.from), this.subject.onSuccess), this.subject)).run(sink);
|
|
541
583
|
}
|
|
542
584
|
runUpdates(run) {
|
|
543
585
|
return this.ref.runUpdates(ref => run({
|
|
@@ -553,7 +595,7 @@ class RefSubjectTransformEffect extends _protos.FxEffectBase {
|
|
|
553
595
|
}));
|
|
554
596
|
}
|
|
555
597
|
unsafeGet = () => {
|
|
556
|
-
return Option.getOrThrowWith(
|
|
598
|
+
return Option.getOrThrowWith(MutableRef.get(this.subject.lastValue), () => new Cause.NoSuchElementException());
|
|
557
599
|
};
|
|
558
600
|
onFailure(cause) {
|
|
559
601
|
return this.subject.onFailure(cause);
|
|
@@ -619,7 +661,7 @@ class RefSubjectTuple extends _protos.FxEffectBase {
|
|
|
619
661
|
this.versioned = Versioned.hold(Versioned.tuple(refs));
|
|
620
662
|
this.version = this.versioned.version;
|
|
621
663
|
this.interrupt = Effect.all(refs.map(r => r.interrupt), UNBOUNDED);
|
|
622
|
-
this.subscriberCount = Effect.map(Effect.all(refs.map(r => r.subscriberCount), UNBOUNDED),
|
|
664
|
+
this.subscriberCount = Effect.map(Effect.all(refs.map(r => r.subscriberCount), UNBOUNDED), Array.reduce(0, _Number.sum));
|
|
623
665
|
this.getSetDelete = {
|
|
624
666
|
get: this.versioned,
|
|
625
667
|
set: a => Effect.all(refs.map((r, i) => set(r, a[i])), UNBOUNDED),
|
|
@@ -686,7 +728,7 @@ class RefSubjectStruct extends _protos.FxEffectBase {
|
|
|
686
728
|
this.versioned = Versioned.hold(Versioned.struct(refs));
|
|
687
729
|
this.version = this.versioned.version;
|
|
688
730
|
this.interrupt = Effect.all(Object.values(refs).map(r => r.interrupt), UNBOUNDED);
|
|
689
|
-
this.subscriberCount = Effect.map(Effect.all(Object.values(refs).map(r => r.subscriberCount), UNBOUNDED),
|
|
731
|
+
this.subscriberCount = Effect.map(Effect.all(Object.values(refs).map(r => r.subscriberCount), UNBOUNDED), Array.reduce(0, _Number.sum));
|
|
690
732
|
this.getSetDelete = {
|
|
691
733
|
get: this.versioned,
|
|
692
734
|
set: a => Effect.all(Object.keys(refs).map(k => set(refs[k], a[k])), UNBOUNDED),
|
|
@@ -766,7 +808,16 @@ class RefSubjectTagged extends _protos.FxEffectBase {
|
|
|
766
808
|
onSuccess(value) {
|
|
767
809
|
return this.tag.withEffect(ref => ref.onSuccess(value));
|
|
768
810
|
}
|
|
769
|
-
|
|
811
|
+
layer = make => this.tag.scoped(make);
|
|
812
|
+
make = (fxOrEffect, options) => {
|
|
813
|
+
return this.tag.scoped(Effect.gen(function* (_) {
|
|
814
|
+
let ref = yield* make(fxOrEffect, options);
|
|
815
|
+
if (options?.drop || options?.take) {
|
|
816
|
+
ref = slice(ref, options.drop ?? 0, options.take ?? Infinity);
|
|
817
|
+
}
|
|
818
|
+
return ref;
|
|
819
|
+
}));
|
|
820
|
+
};
|
|
770
821
|
}
|
|
771
822
|
/**
|
|
772
823
|
* @since 1.20.0
|
|
@@ -789,7 +840,7 @@ class RefSubjectFromTag extends _protos.FxEffectBase {
|
|
|
789
840
|
this.tag = tag;
|
|
790
841
|
this.f = f;
|
|
791
842
|
this._get = Effect.map(tag, f);
|
|
792
|
-
this._fx =
|
|
843
|
+
this._fx = internal.fromFxEffect(this._get);
|
|
793
844
|
this.version = Effect.flatMap(this._get, ref => ref.version);
|
|
794
845
|
this.interrupt = Effect.flatMap(this._get, ref => ref.interrupt);
|
|
795
846
|
this.subscriberCount = Effect.flatMap(this._get, ref => ref.subscriberCount);
|
|
@@ -961,7 +1012,7 @@ const decrement = ref => update(ref, sub);
|
|
|
961
1012
|
*/
|
|
962
1013
|
exports.decrement = decrement;
|
|
963
1014
|
const slice = exports.slice = /*#__PURE__*/(0, _Function.dual)(3, function slice(ref, drop, take) {
|
|
964
|
-
return new
|
|
1015
|
+
return new RefSubjectSimpleTransform(ref, _ => internal.slice(_, drop, take), _Function.identity);
|
|
965
1016
|
});
|
|
966
1017
|
/**
|
|
967
1018
|
* @since 1.20.0
|
|
@@ -975,32 +1026,74 @@ const drop = exports.drop = /*#__PURE__*/(0, _Function.dual)(2, function drop(re
|
|
|
975
1026
|
const take = exports.take = /*#__PURE__*/(0, _Function.dual)(2, function take(ref, take) {
|
|
976
1027
|
return slice(ref, 0, take);
|
|
977
1028
|
});
|
|
978
|
-
|
|
1029
|
+
/**
|
|
1030
|
+
* Get the current value of the RefSubject. If it has not been set yet, a Fiber will be used to wait for the value to be set.
|
|
1031
|
+
*
|
|
1032
|
+
* @since 1.25.0
|
|
1033
|
+
*/
|
|
1034
|
+
const get = ref => ref;
|
|
1035
|
+
/**
|
|
1036
|
+
* Synchronously get the current Exit value of the RefSubject. If it has not been set yet, a Cause.NoSuchElementException will be thrown.
|
|
1037
|
+
*
|
|
1038
|
+
* Note: This is unimplemented for RefSubject.tagged and RefSubject.fromTag because they require the Effect context by definition.
|
|
1039
|
+
* It will throw immediately.
|
|
1040
|
+
*
|
|
1041
|
+
* @since 1.25.0
|
|
1042
|
+
*/
|
|
1043
|
+
exports.get = get;
|
|
1044
|
+
const unsafeGetExit = ref => ref.unsafeGet();
|
|
1045
|
+
/**
|
|
1046
|
+
* Synchronously get the current value of the RefSubject.
|
|
1047
|
+
*
|
|
1048
|
+
* @since 1.25.0
|
|
1049
|
+
*/
|
|
1050
|
+
exports.unsafeGetExit = unsafeGetExit;
|
|
1051
|
+
const unsafeGet = ref => Effect.runSync(unsafeGetExit(ref));
|
|
1052
|
+
/**
|
|
1053
|
+
* Extract all values from an object using a Proxy
|
|
1054
|
+
*
|
|
1055
|
+
* @since 2.0.0
|
|
1056
|
+
*/
|
|
1057
|
+
exports.unsafeGet = unsafeGet;
|
|
1058
|
+
const proxy = source => {
|
|
1059
|
+
const target = {};
|
|
1060
|
+
return new Proxy(target, {
|
|
1061
|
+
get(self, prop) {
|
|
1062
|
+
if (prop in self) return self[prop];
|
|
1063
|
+
return self[prop] = map(source, a => a[prop]);
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
};
|
|
1067
|
+
/**
|
|
1068
|
+
* @since 2.0.0
|
|
1069
|
+
*/
|
|
1070
|
+
exports.proxy = proxy;
|
|
1071
|
+
const withSpan = exports.withSpan = /*#__PURE__*/(0, _Function.dual)(isRefSubjectDataFirst, (ref, name, options) => new RefSubjectSimpleTransform(ref, fx => internal.withSpan(fx, name, options), Effect.withSpan(name, options)));
|
|
1072
|
+
class RefSubjectSimpleTransform extends _protos.FxEffectBase {
|
|
979
1073
|
ref;
|
|
980
|
-
|
|
981
|
-
|
|
1074
|
+
transformFx;
|
|
1075
|
+
transformEffect;
|
|
982
1076
|
[_TypeId.ComputedTypeId] = _TypeId.ComputedTypeId;
|
|
983
1077
|
[_TypeId.RefSubjectTypeId] = _TypeId.RefSubjectTypeId;
|
|
984
1078
|
version;
|
|
985
1079
|
interrupt;
|
|
986
1080
|
subscriberCount;
|
|
987
1081
|
_fx;
|
|
988
|
-
constructor(ref,
|
|
1082
|
+
constructor(ref, transformFx, transformEffect) {
|
|
989
1083
|
super();
|
|
990
1084
|
this.ref = ref;
|
|
991
|
-
this.
|
|
992
|
-
this.
|
|
1085
|
+
this.transformFx = transformFx;
|
|
1086
|
+
this.transformEffect = transformEffect;
|
|
993
1087
|
this.version = ref.version;
|
|
994
1088
|
this.interrupt = ref.interrupt;
|
|
995
1089
|
this.subscriberCount = ref.subscriberCount;
|
|
996
|
-
this._fx =
|
|
997
|
-
this._effect = ref;
|
|
1090
|
+
this._fx = transformFx(ref);
|
|
998
1091
|
}
|
|
999
1092
|
run(sink) {
|
|
1000
1093
|
return this._fx.run(sink);
|
|
1001
1094
|
}
|
|
1002
1095
|
toEffect() {
|
|
1003
|
-
return this.ref;
|
|
1096
|
+
return this.transformEffect(this.ref);
|
|
1004
1097
|
}
|
|
1005
1098
|
runUpdates(run) {
|
|
1006
1099
|
return this.ref.runUpdates(run);
|
|
@@ -1014,27 +1107,9 @@ class RefSubjectSlice extends _protos.FxEffectBase {
|
|
|
1014
1107
|
}
|
|
1015
1108
|
}
|
|
1016
1109
|
/**
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* @since 1.25.0
|
|
1110
|
+
* @since 2.0.0
|
|
1020
1111
|
*/
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
*
|
|
1025
|
-
* Note: This is unimplemented for RefSubject.tagged and RefSubject.fromTag because they require the Effect context by definition.
|
|
1026
|
-
* It will throw immediately.
|
|
1027
|
-
*
|
|
1028
|
-
* @since 1.25.0
|
|
1029
|
-
*/
|
|
1030
|
-
exports.get = get;
|
|
1031
|
-
const unsafeGetExit = ref => ref.unsafeGet();
|
|
1032
|
-
/**
|
|
1033
|
-
* Synchronously get the current value of the RefSubject.
|
|
1034
|
-
*
|
|
1035
|
-
* @since 1.25.0
|
|
1036
|
-
*/
|
|
1037
|
-
exports.unsafeGetExit = unsafeGetExit;
|
|
1038
|
-
const unsafeGet = ref => Effect.runSync(unsafeGetExit(ref));
|
|
1039
|
-
exports.unsafeGet = unsafeGet;
|
|
1112
|
+
const when = exports.when = /*#__PURE__*/(0, _Function.dual)(2, function when(ref, options) {
|
|
1113
|
+
return map(ref, a => a ? options.onTrue : options.onFalse);
|
|
1114
|
+
});
|
|
1040
1115
|
//# sourceMappingURL=RefSubject.js.map
|