@expressive/mvc 0.1.0 → 0.1.1
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 +5 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -581,7 +581,7 @@ declare function tap<T extends Class>(Type: T, required?: boolean): InstanceOf<T
|
|
|
581
581
|
declare function useFrom<T extends Stateful, R>(source: (() => T) | T, compute: (this: T, from: T) => R, expect: true): Exclude<R, undefined>;
|
|
582
582
|
declare function useFrom<T extends Stateful, R>(source: (() => T) | T, compute: (this: T, from: T) => R, expect?: boolean): R;
|
|
583
583
|
|
|
584
|
-
declare function
|
|
584
|
+
declare function useLocal<T extends typeof Model>(Type: T, arg?: boolean | string): any;
|
|
585
585
|
|
|
586
586
|
declare function useModel<T extends Class, I extends InstanceOf<T>>(source: T, watch: Model.Field<I>[], callback?: (instance: I) => void): I;
|
|
587
587
|
declare function useModel<T extends Class, I extends InstanceOf<T>>(source: T, callback?: (instance: I) => void): I;
|
|
@@ -603,4 +603,4 @@ declare function useTap<T extends Stateful, K extends Model.Field<T>>(source: T
|
|
|
603
603
|
declare function useTap<T extends Stateful, R>(source: T | (() => T) | useTap.Tappable, compute: (this: T, from: T) => R, expect: true): Exclude<R, undefined>;
|
|
604
604
|
declare function useTap<T extends Stateful, R>(source: T | (() => T) | useTap.Tappable, compute: (this: T, from: T) => R, expect?: boolean): R;
|
|
605
605
|
|
|
606
|
-
export { CONTROL, Consumer, Global, LOCAL, MVC as Model, Provider, STATE, Stateful, WHY, act, apply, array, MVC as default, from, parent, ref, set, tap, use, useFrom,
|
|
606
|
+
export { CONTROL, Consumer, Global, LOCAL, MVC as Model, Provider, STATE, Stateful, WHY, act, apply, array, MVC as default, from, parent, ref, set, tap, use, useFrom, useLocal, useModel, useTap };
|
package/lib/index.esm.js
CHANGED
|
@@ -1031,7 +1031,7 @@ const useLookup = () => React.useContext(LookupContext);
|
|
|
1031
1031
|
const Oops$4 = issues({
|
|
1032
1032
|
NothingInContext: (name) => `Couldn't find ${name} in context; did you forget to use a Provider?`
|
|
1033
1033
|
});
|
|
1034
|
-
function
|
|
1034
|
+
function useLocal(Type, arg) {
|
|
1035
1035
|
const instance = useLookup().get(Type);
|
|
1036
1036
|
if (!instance && arg !== false)
|
|
1037
1037
|
throw Oops$4.NothingInContext(Type.name);
|
|
@@ -1199,7 +1199,7 @@ function useTap(source, path, expect) {
|
|
|
1199
1199
|
if ("get" in source)
|
|
1200
1200
|
return () => source.get();
|
|
1201
1201
|
if ("prototype" in source)
|
|
1202
|
-
return () =>
|
|
1202
|
+
return () => useLocal(source);
|
|
1203
1203
|
else
|
|
1204
1204
|
return source;
|
|
1205
1205
|
}, [])();
|
|
@@ -1234,7 +1234,7 @@ class MVC extends Model {
|
|
|
1234
1234
|
return useModel(this, arg, callback);
|
|
1235
1235
|
}
|
|
1236
1236
|
static get(required) {
|
|
1237
|
-
return
|
|
1237
|
+
return useLocal(this, required);
|
|
1238
1238
|
}
|
|
1239
1239
|
static tap(key, expect) {
|
|
1240
1240
|
return useTap(this, key, expect);
|
|
@@ -1288,7 +1288,7 @@ function Consumer(props) {
|
|
|
1288
1288
|
return children(useTap(Control));
|
|
1289
1289
|
const callback = has || get;
|
|
1290
1290
|
if (typeof callback == "function")
|
|
1291
|
-
callback(
|
|
1291
|
+
callback(useLocal(Control, !!has));
|
|
1292
1292
|
else
|
|
1293
1293
|
throw Oops$2.BadConsumerProps();
|
|
1294
1294
|
return null;
|
|
@@ -1388,5 +1388,5 @@ class Global extends MVC {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
1390
|
|
|
1391
|
-
export { CONTROL, Consumer, Global, LOCAL, MVC as Model, Provider, STATE, WHY, act, apply, array, MVC as default, from, parent, ref, set, tap, use$1 as use, useFrom,
|
|
1391
|
+
export { CONTROL, Consumer, Global, LOCAL, MVC as Model, Provider, STATE, WHY, act, apply, array, MVC as default, from, parent, ref, set, tap, use$1 as use, useFrom, useLocal, useModel, useTap };
|
|
1392
1392
|
//# sourceMappingURL=index.esm.js.map
|