mol_wire_lib 1.0.172 → 1.0.175

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/node.test.js CHANGED
@@ -608,12 +608,13 @@ var $;
608
608
  field() {
609
609
  return this.task.name + '()';
610
610
  }
611
- constructor(id, task, host, ...args) {
611
+ constructor(id, task, host, args) {
612
612
  super();
613
613
  this.task = task;
614
614
  this.host = host;
615
- this.data.push(...args);
616
- this.pub_from = this.sub_from = args.length;
615
+ if (args)
616
+ this.data.push(...args);
617
+ this.pub_from = this.sub_from = args?.length ?? 0;
617
618
  this[Symbol.toStringTag] = id;
618
619
  }
619
620
  plan() {
@@ -674,7 +675,7 @@ var $;
674
675
  result = this.task.call(this.host, this.data[0]);
675
676
  break;
676
677
  default:
677
- result = this.task.call(this.host, ...this.data.slice(0, this.pub_from));
678
+ result = this.task.call(this.host, ...this.args);
678
679
  break;
679
680
  }
680
681
  if (result instanceof Promise) {
@@ -888,7 +889,7 @@ var $;
888
889
  break reuse;
889
890
  return existen;
890
891
  }
891
- return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
892
+ return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
892
893
  };
893
894
  }
894
895
  complete() {
@@ -1013,7 +1014,7 @@ var $;
1013
1014
  else {
1014
1015
  dict = (host ?? task)[field] = new Map();
1015
1016
  }
1016
- fiber = new $mol_wire_atom(key, task, host, ...args);
1017
+ fiber = new $mol_wire_atom(key, task, host, args);
1017
1018
  dict.set(key, fiber);
1018
1019
  return fiber;
1019
1020
  };
@@ -1024,33 +1025,14 @@ var $;
1024
1025
  if (existen)
1025
1026
  return existen;
1026
1027
  const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
1027
- const fiber = new $mol_wire_atom(key, task, host, ...args);
1028
+ const fiber = new $mol_wire_atom(key, task, host, args);
1028
1029
  (host ?? task)[field] = fiber;
1029
1030
  return fiber;
1030
1031
  };
1031
1032
  }
1032
1033
  }
1033
- resync(...args) {
1034
- let res;
1035
- try {
1036
- res = this.recall(...args);
1037
- }
1038
- catch (error) {
1039
- if (error instanceof Promise)
1040
- $mol_fail_hidden(error);
1041
- res = error;
1042
- }
1043
- try {
1044
- this.once();
1045
- }
1046
- catch (error) {
1047
- if (error instanceof Promise)
1048
- $mol_fail_hidden(error);
1049
- }
1050
- return this.put(res);
1051
- }
1052
- recall(...args) {
1053
- return this.task.call(this.host, ...args);
1034
+ resync(args) {
1035
+ return this.put(this.task.call(this.host, ...args));
1054
1036
  }
1055
1037
  once() {
1056
1038
  return this.sync();
@@ -1099,9 +1081,6 @@ var $;
1099
1081
  __decorate([
1100
1082
  $mol_wire_method
1101
1083
  ], $mol_wire_atom.prototype, "resync", null);
1102
- __decorate([
1103
- $mol_wire_method
1104
- ], $mol_wire_atom.prototype, "recall", null);
1105
1084
  __decorate([
1106
1085
  $mol_wire_method
1107
1086
  ], $mol_wire_atom.prototype, "once", null);
@@ -1210,7 +1189,7 @@ var $;
1210
1189
  let atom = persist(this, args.slice(0, keys));
1211
1190
  if (args.length <= keys || args[keys] === undefined) {
1212
1191
  if (!$mol_wire_fiber.warm)
1213
- return atom.sync();
1192
+ return atom.result();
1214
1193
  if ($mol_wire_auto() instanceof $mol_wire_task) {
1215
1194
  return atom.once();
1216
1195
  }
@@ -1218,7 +1197,7 @@ var $;
1218
1197
  return atom.sync();
1219
1198
  }
1220
1199
  }
1221
- return atom.resync(...args);
1200
+ return atom.resync(args);
1222
1201
  };
1223
1202
  Object.defineProperty(wrapper, 'name', { value: func.name + ' ' });
1224
1203
  Object.assign(wrapper, { orig: func });
@@ -3117,33 +3096,6 @@ var $;
3117
3096
  ], App, "test", null);
3118
3097
  App.test();
3119
3098
  },
3120
- 'Update deps on push'($) {
3121
- class App extends $mol_object2 {
3122
- static $ = $;
3123
- static left(next = false) {
3124
- return next;
3125
- }
3126
- static right(next = false) {
3127
- return next;
3128
- }
3129
- static res(next) {
3130
- return this.left(next) && this.right();
3131
- }
3132
- }
3133
- __decorate([
3134
- $mol_wire_mem(0)
3135
- ], App, "left", null);
3136
- __decorate([
3137
- $mol_wire_mem(0)
3138
- ], App, "right", null);
3139
- __decorate([
3140
- $mol_wire_mem(0)
3141
- ], App, "res", null);
3142
- $mol_assert_equal(App.res(), false);
3143
- $mol_assert_equal(App.res(true), false);
3144
- $mol_assert_equal(App.right(true), true);
3145
- $mol_assert_equal(App.res(), true);
3146
- },
3147
3099
  'Different order of pull and push'($) {
3148
3100
  class App extends $mol_object2 {
3149
3101
  static $ = $;
@@ -3154,6 +3106,8 @@ var $;
3154
3106
  return this.store(next);
3155
3107
  }
3156
3108
  static slow(next) {
3109
+ if (next !== undefined)
3110
+ this.slow();
3157
3111
  return this.store(next);
3158
3112
  }
3159
3113
  }