mol_wire_lib 1.0.792 → 1.0.794

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.mjs CHANGED
@@ -776,12 +776,26 @@ var $;
776
776
  }
777
777
  if (!$mol_promise_like(this.cache))
778
778
  return this.cache;
779
- await this.cache;
779
+ await Promise.race([this.cache, this.step()]);
780
+ if (!$mol_promise_like(this.cache))
781
+ return this.cache;
780
782
  if (this.cursor === $mol_wire_cursor.final) {
781
783
  await new Promise(() => { });
782
784
  }
783
785
  }
784
786
  }
787
+ step() {
788
+ return new Promise(done => {
789
+ const sub = new $mol_wire_pub_sub;
790
+ const prev = sub.track_on();
791
+ sub.track_next(this);
792
+ sub.track_off(prev);
793
+ sub.absorb = () => {
794
+ done(null);
795
+ sub.destructor();
796
+ };
797
+ });
798
+ }
785
799
  }
786
800
  $.$mol_wire_fiber = $mol_wire_fiber;
787
801
  })($ || ($ = {}));
package/node.test.js CHANGED
@@ -768,12 +768,26 @@ var $;
768
768
  }
769
769
  if (!$mol_promise_like(this.cache))
770
770
  return this.cache;
771
- await this.cache;
771
+ await Promise.race([this.cache, this.step()]);
772
+ if (!$mol_promise_like(this.cache))
773
+ return this.cache;
772
774
  if (this.cursor === $mol_wire_cursor.final) {
773
775
  await new Promise(() => { });
774
776
  }
775
777
  }
776
778
  }
779
+ step() {
780
+ return new Promise(done => {
781
+ const sub = new $mol_wire_pub_sub;
782
+ const prev = sub.track_on();
783
+ sub.track_next(this);
784
+ sub.track_off(prev);
785
+ sub.absorb = () => {
786
+ done(null);
787
+ sub.destructor();
788
+ };
789
+ });
790
+ }
777
791
  }
778
792
  $.$mol_wire_fiber = $mol_wire_fiber;
779
793
  })($ || ($ = {}));
@@ -4471,6 +4485,31 @@ var $;
4471
4485
  var $;
4472
4486
  (function ($_1) {
4473
4487
  $mol_test({
4488
+ async 'Error caching'($) {
4489
+ const next_cached = 123;
4490
+ class Some extends $mol_object2 {
4491
+ static $ = $;
4492
+ static data(id, next) {
4493
+ if (next)
4494
+ return next;
4495
+ setTimeout(() => {
4496
+ $mol_wire_async(this).data(id, next_cached);
4497
+ }, 10);
4498
+ $mol_fail_hidden(new Promise(() => { }));
4499
+ }
4500
+ static run() {
4501
+ return this.data('1');
4502
+ }
4503
+ }
4504
+ __decorate([
4505
+ $mol_wire_plex
4506
+ ], Some, "data", null);
4507
+ __decorate([
4508
+ $mol_wire_method
4509
+ ], Some, "run", null);
4510
+ const val = await $mol_wire_async(Some).run();
4511
+ $mol_assert_equal(val, next_cached);
4512
+ },
4474
4513
  'Memoize by single simple key'($) {
4475
4514
  class Team extends $mol_object2 {
4476
4515
  static $ = $;