@expressive/mvc 0.21.3 → 0.21.8
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.d.ts +2 -2
- package/lib/index.esm.js +23 -11
- package/lib/index.js +23 -11
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare namespace Control {
|
|
|
71
71
|
*/
|
|
72
72
|
type OnReady<T extends Model> = (control: Control<T>) => Callback | void;
|
|
73
73
|
type RequestRefresh = (update: (tick: number) => number) => void;
|
|
74
|
-
type
|
|
74
|
+
type GetContext = (target: Model) => (callback: (got: Context) => void) => void;
|
|
75
75
|
type GetAdapter<T> = (refresh: RequestRefresh, context: Context) => {
|
|
76
76
|
mount: () => (() => void) | void;
|
|
77
77
|
render: () => T;
|
|
@@ -92,7 +92,7 @@ declare class Control<T extends Model = any> {
|
|
|
92
92
|
static pending: Set<Callback>;
|
|
93
93
|
static get: Control.GetHook;
|
|
94
94
|
static use: Control.UseHook;
|
|
95
|
-
static has: Control.
|
|
95
|
+
static has: Control.GetContext;
|
|
96
96
|
static for: typeof control;
|
|
97
97
|
static apply: typeof apply;
|
|
98
98
|
static watch: typeof watch;
|
package/lib/index.esm.js
CHANGED
|
@@ -659,12 +659,16 @@ function get(arg0, arg1) {
|
|
|
659
659
|
if (!hasParent) {
|
|
660
660
|
if (arg1 === true)
|
|
661
661
|
throw Oops$3.Required(arg0, subject);
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
662
|
+
const fetch = Control.has(subject);
|
|
663
|
+
source = got => {
|
|
664
|
+
fetch(context => {
|
|
665
|
+
const model = context.get(arg0);
|
|
666
|
+
if (model)
|
|
667
|
+
got(model);
|
|
668
|
+
else if (arg1 !== false)
|
|
669
|
+
throw Oops$3.AmbientRequired(arg0, subject);
|
|
670
|
+
});
|
|
671
|
+
};
|
|
668
672
|
}
|
|
669
673
|
else if (!arg0 || hasParent instanceof arg0)
|
|
670
674
|
subject = hasParent;
|
|
@@ -862,18 +866,26 @@ function set(value, argument) {
|
|
|
862
866
|
return getter();
|
|
863
867
|
};
|
|
864
868
|
}
|
|
869
|
+
let setter = typeof argument == "function"
|
|
870
|
+
? createValueEffect(argument)
|
|
871
|
+
: undefined;
|
|
865
872
|
if (value !== undefined)
|
|
866
873
|
state[key] = value;
|
|
874
|
+
else if (setter) {
|
|
875
|
+
const effect = setter;
|
|
876
|
+
setter = function (value) {
|
|
877
|
+
if (!(key in state))
|
|
878
|
+
state[key] = undefined;
|
|
879
|
+
return effect.call(this, value);
|
|
880
|
+
};
|
|
881
|
+
}
|
|
867
882
|
return {
|
|
868
883
|
get: () => {
|
|
869
884
|
if (key in state)
|
|
870
885
|
return state[key];
|
|
871
|
-
|
|
872
|
-
throw suspense(control, key);
|
|
886
|
+
throw suspense(control, key);
|
|
873
887
|
},
|
|
874
|
-
set:
|
|
875
|
-
? createValueEffect(argument)
|
|
876
|
-
: undefined
|
|
888
|
+
set: setter
|
|
877
889
|
};
|
|
878
890
|
});
|
|
879
891
|
}
|
package/lib/index.js
CHANGED
|
@@ -663,12 +663,16 @@ function get(arg0, arg1) {
|
|
|
663
663
|
if (!hasParent) {
|
|
664
664
|
if (arg1 === true)
|
|
665
665
|
throw Oops$3.Required(arg0, subject);
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
666
|
+
const fetch = Control.has(subject);
|
|
667
|
+
source = got => {
|
|
668
|
+
fetch(context => {
|
|
669
|
+
const model = context.get(arg0);
|
|
670
|
+
if (model)
|
|
671
|
+
got(model);
|
|
672
|
+
else if (arg1 !== false)
|
|
673
|
+
throw Oops$3.AmbientRequired(arg0, subject);
|
|
674
|
+
});
|
|
675
|
+
};
|
|
672
676
|
}
|
|
673
677
|
else if (!arg0 || hasParent instanceof arg0)
|
|
674
678
|
subject = hasParent;
|
|
@@ -866,18 +870,26 @@ function set(value, argument) {
|
|
|
866
870
|
return getter();
|
|
867
871
|
};
|
|
868
872
|
}
|
|
873
|
+
let setter = typeof argument == "function"
|
|
874
|
+
? createValueEffect(argument)
|
|
875
|
+
: undefined;
|
|
869
876
|
if (value !== undefined)
|
|
870
877
|
state[key] = value;
|
|
878
|
+
else if (setter) {
|
|
879
|
+
const effect = setter;
|
|
880
|
+
setter = function (value) {
|
|
881
|
+
if (!(key in state))
|
|
882
|
+
state[key] = undefined;
|
|
883
|
+
return effect.call(this, value);
|
|
884
|
+
};
|
|
885
|
+
}
|
|
871
886
|
return {
|
|
872
887
|
get: () => {
|
|
873
888
|
if (key in state)
|
|
874
889
|
return state[key];
|
|
875
|
-
|
|
876
|
-
throw suspense(control, key);
|
|
890
|
+
throw suspense(control, key);
|
|
877
891
|
},
|
|
878
|
-
set:
|
|
879
|
-
? createValueEffect(argument)
|
|
880
|
-
: undefined
|
|
892
|
+
set: setter
|
|
881
893
|
};
|
|
882
894
|
});
|
|
883
895
|
}
|
package/package.json
CHANGED