@expressive/mvc 0.29.1 → 0.29.2
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/lib/index.esm.js +10 -11
- package/lib/index.js +10 -11
- package/package.json +2 -2
package/lib/index.esm.js
CHANGED
|
@@ -254,11 +254,13 @@ function createEffect(source, callback) {
|
|
|
254
254
|
return () => refresh = null;
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
-
function createValueEffect(callback) {
|
|
257
|
+
function createValueEffect(callback, ignoreNull) {
|
|
258
258
|
let unSet;
|
|
259
259
|
return function (value) {
|
|
260
260
|
if (typeof unSet == "function")
|
|
261
|
-
unSet(value);
|
|
261
|
+
unSet = void unSet(value);
|
|
262
|
+
if (value === null && ignoreNull)
|
|
263
|
+
return;
|
|
262
264
|
const out = callback.call(this, value);
|
|
263
265
|
if (typeof out == "boolean")
|
|
264
266
|
return out;
|
|
@@ -775,33 +777,30 @@ function flushComputed() {
|
|
|
775
777
|
}
|
|
776
778
|
Control.before.add(flushComputed);
|
|
777
779
|
|
|
778
|
-
function ref(arg,
|
|
780
|
+
function ref(arg, arg2) {
|
|
779
781
|
return apply((key, source) => {
|
|
780
782
|
let value = {};
|
|
781
783
|
if (typeof arg == "object")
|
|
782
|
-
for (const key in control(arg, true).state)
|
|
783
|
-
defineProperty(value, key, typeof
|
|
784
|
+
for (const key in control(arg, true).state)
|
|
785
|
+
defineProperty(value, key, typeof arg2 == "function" ? {
|
|
784
786
|
configurable: true,
|
|
785
787
|
get() {
|
|
786
|
-
const out =
|
|
788
|
+
const out = arg2(key);
|
|
787
789
|
defineProperty(value, key, { value: out });
|
|
788
790
|
return out;
|
|
789
791
|
}
|
|
790
792
|
} : {
|
|
791
793
|
value: createRef(source, key)
|
|
792
794
|
});
|
|
793
|
-
}
|
|
794
795
|
else
|
|
795
|
-
value = createRef(source, key, arg &&
|
|
796
|
-
? (x) => x !== null ? arg(x) : undefined
|
|
797
|
-
: arg);
|
|
796
|
+
value = createRef(source, key, arg && createValueEffect(arg, arg2 !== false));
|
|
798
797
|
source.state[key] = undefined;
|
|
799
798
|
source.observers.set(key, new Set());
|
|
800
799
|
defineProperty(source.subject, key, { value });
|
|
801
800
|
});
|
|
802
801
|
}
|
|
803
802
|
function createRef(src, key, cb) {
|
|
804
|
-
const refObjectFunction = src.ref(key, cb
|
|
803
|
+
const refObjectFunction = src.ref(key, cb);
|
|
805
804
|
defineProperty(refObjectFunction, "current", {
|
|
806
805
|
set: refObjectFunction,
|
|
807
806
|
get: () => src.state[key]
|
package/lib/index.js
CHANGED
|
@@ -258,11 +258,13 @@ function createEffect(source, callback) {
|
|
|
258
258
|
return () => refresh = null;
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
function createValueEffect(callback) {
|
|
261
|
+
function createValueEffect(callback, ignoreNull) {
|
|
262
262
|
let unSet;
|
|
263
263
|
return function (value) {
|
|
264
264
|
if (typeof unSet == "function")
|
|
265
|
-
unSet(value);
|
|
265
|
+
unSet = void unSet(value);
|
|
266
|
+
if (value === null && ignoreNull)
|
|
267
|
+
return;
|
|
266
268
|
const out = callback.call(this, value);
|
|
267
269
|
if (typeof out == "boolean")
|
|
268
270
|
return out;
|
|
@@ -779,33 +781,30 @@ function flushComputed() {
|
|
|
779
781
|
}
|
|
780
782
|
Control.before.add(flushComputed);
|
|
781
783
|
|
|
782
|
-
function ref(arg,
|
|
784
|
+
function ref(arg, arg2) {
|
|
783
785
|
return apply((key, source) => {
|
|
784
786
|
let value = {};
|
|
785
787
|
if (typeof arg == "object")
|
|
786
|
-
for (const key in control(arg, true).state)
|
|
787
|
-
defineProperty(value, key, typeof
|
|
788
|
+
for (const key in control(arg, true).state)
|
|
789
|
+
defineProperty(value, key, typeof arg2 == "function" ? {
|
|
788
790
|
configurable: true,
|
|
789
791
|
get() {
|
|
790
|
-
const out =
|
|
792
|
+
const out = arg2(key);
|
|
791
793
|
defineProperty(value, key, { value: out });
|
|
792
794
|
return out;
|
|
793
795
|
}
|
|
794
796
|
} : {
|
|
795
797
|
value: createRef(source, key)
|
|
796
798
|
});
|
|
797
|
-
}
|
|
798
799
|
else
|
|
799
|
-
value = createRef(source, key, arg &&
|
|
800
|
-
? (x) => x !== null ? arg(x) : undefined
|
|
801
|
-
: arg);
|
|
800
|
+
value = createRef(source, key, arg && createValueEffect(arg, arg2 !== false));
|
|
802
801
|
source.state[key] = undefined;
|
|
803
802
|
source.observers.set(key, new Set());
|
|
804
803
|
defineProperty(source.subject, key, { value });
|
|
805
804
|
});
|
|
806
805
|
}
|
|
807
806
|
function createRef(src, key, cb) {
|
|
808
|
-
const refObjectFunction = src.ref(key, cb
|
|
807
|
+
const refObjectFunction = src.ref(key, cb);
|
|
809
808
|
defineProperty(refObjectFunction, "current", {
|
|
810
809
|
set: refObjectFunction,
|
|
811
810
|
get: () => src.state[key]
|
package/package.json
CHANGED