@expressive/mvc 1.0.0-beta.39 → 1.0.0-beta.41
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 +11 -3
- package/lib/index.esm.js +25 -17
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +25 -17
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -442,11 +442,19 @@ declare class MVC extends Model {
|
|
|
442
442
|
*
|
|
443
443
|
* @param callback - Run after creation of instance.
|
|
444
444
|
*/
|
|
445
|
-
static new<T extends Class
|
|
445
|
+
static new<T extends Class, I extends InstanceOf<T>>(this: T, callback?: (instance: I) => void): I;
|
|
446
|
+
static new<T extends Class, I extends InstanceOf<T>>(this: T, apply: Model.Compat<I>): I;
|
|
446
447
|
static use<T extends Class, I extends InstanceOf<T>>(this: T, watch: Model.Field<I>[], callback?: (instance: I) => void): I;
|
|
447
448
|
static use<T extends Class, I extends InstanceOf<T>>(this: T, callback?: (instance: I) => void): I;
|
|
448
|
-
static
|
|
449
|
-
|
|
449
|
+
static use<T extends Class, I extends InstanceOf<T>>(this: T, apply: Model.Compat<I>, keys?: Model.Event<I>[]): I;
|
|
450
|
+
/**
|
|
451
|
+
* @deprecated consider doing this manually - not worth minor efficiency gain over using.
|
|
452
|
+
*/
|
|
453
|
+
static uses<T extends typeof MVC, I extends InstanceOf<T>, D extends Model.Compat<I>>(this: T, apply: D, keys?: (keyof D)[]): InstanceOf<T>;
|
|
454
|
+
/**
|
|
455
|
+
* @deprecated is now replaced by overload of `use` method.
|
|
456
|
+
*/
|
|
457
|
+
static using<T extends typeof MVC, I extends InstanceOf<T>>(this: T, apply: Model.Compat<I>, keys?: Model.Event<I>[]): I;
|
|
450
458
|
static meta<T extends Class>(this: T): T;
|
|
451
459
|
static meta<T extends Class, K extends keyof T>(this: T, key: K, expect: true): Exclude<T[K], undefined>;
|
|
452
460
|
static meta<T extends Class, K extends keyof T>(this: T, key: K, expect?: boolean): T[K];
|
package/lib/index.esm.js
CHANGED
|
@@ -1120,30 +1120,38 @@ class MVC extends Model {
|
|
|
1120
1120
|
static tap(key, expect) {
|
|
1121
1121
|
return useTap(this, key, expect);
|
|
1122
1122
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1123
|
+
static new(arg) {
|
|
1124
|
+
return React.useMemo(() => {
|
|
1125
|
+
const instance = new this();
|
|
1126
|
+
control(instance);
|
|
1127
|
+
if (typeof arg == "function")
|
|
1128
|
+
arg(instance);
|
|
1129
|
+
else if (arg)
|
|
1130
|
+
getOwnPropertyNames(instance).forEach(key => {
|
|
1131
|
+
if (key in arg)
|
|
1132
|
+
instance[key] = arg[key];
|
|
1133
|
+
});
|
|
1134
|
+
return instance;
|
|
1135
|
+
}, []);
|
|
1132
1136
|
}
|
|
1133
|
-
static use(
|
|
1134
|
-
const instance = useModel(this,
|
|
1137
|
+
static use(a, b) {
|
|
1138
|
+
const instance = useModel(this, a, b);
|
|
1135
1139
|
usePeerContext(instance.get);
|
|
1136
1140
|
return instance;
|
|
1137
1141
|
}
|
|
1138
|
-
|
|
1142
|
+
/**
|
|
1143
|
+
* @deprecated consider doing this manually - not worth minor efficiency gain over using.
|
|
1144
|
+
*/
|
|
1145
|
+
static uses(apply, keys) {
|
|
1139
1146
|
return this.use(instance => {
|
|
1140
|
-
instance.import(
|
|
1147
|
+
instance.import(apply, keys);
|
|
1141
1148
|
});
|
|
1142
1149
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1150
|
+
/**
|
|
1151
|
+
* @deprecated is now replaced by overload of `use` method.
|
|
1152
|
+
*/
|
|
1153
|
+
static using(apply, keys) {
|
|
1154
|
+
return this.use(apply, keys);
|
|
1147
1155
|
}
|
|
1148
1156
|
static meta(path, expect) {
|
|
1149
1157
|
return useTap(() => this, path, expect);
|