@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.js CHANGED
@@ -1128,30 +1128,38 @@ class MVC extends Model {
1128
1128
  static tap(key, expect) {
1129
1129
  return useTap(this, key, expect);
1130
1130
  }
1131
- /**
1132
- * **React Hook** - Spawn and maintain a controller from within a component.
1133
- *
1134
- * More efficient than `use()` if you don't need hook-based features.
1135
- *
1136
- * @param callback - Run after creation of instance.
1137
- */
1138
- static new(callback) {
1139
- return useModel(this, [], callback);
1131
+ static new(arg) {
1132
+ return React__default["default"].useMemo(() => {
1133
+ const instance = new this();
1134
+ control(instance);
1135
+ if (typeof arg == "function")
1136
+ arg(instance);
1137
+ else if (arg)
1138
+ getOwnPropertyNames(instance).forEach(key => {
1139
+ if (key in arg)
1140
+ instance[key] = arg[key];
1141
+ });
1142
+ return instance;
1143
+ }, []);
1140
1144
  }
1141
- static use(arg, callback) {
1142
- const instance = useModel(this, arg, callback);
1145
+ static use(a, b) {
1146
+ const instance = useModel(this, a, b);
1143
1147
  usePeerContext(instance.get);
1144
1148
  return instance;
1145
1149
  }
1146
- static uses(data, only) {
1150
+ /**
1151
+ * @deprecated consider doing this manually - not worth minor efficiency gain over using.
1152
+ */
1153
+ static uses(apply, keys) {
1147
1154
  return this.use(instance => {
1148
- instance.import(data, only);
1155
+ instance.import(apply, keys);
1149
1156
  });
1150
1157
  }
1151
- static using(data, only) {
1152
- const instance = this.use();
1153
- instance.import(data, only);
1154
- return instance;
1158
+ /**
1159
+ * @deprecated is now replaced by overload of `use` method.
1160
+ */
1161
+ static using(apply, keys) {
1162
+ return this.use(apply, keys);
1155
1163
  }
1156
1164
  static meta(path, expect) {
1157
1165
  return useTap(() => this, path, expect);