Skip to content

Commit

Permalink
$mol_wire_fiber: track changes while await
Browse files Browse the repository at this point in the history
  • Loading branch information
jin committed Nov 5, 2023
1 parent 6d5a980 commit 686be28
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion wire/fiber/fiber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,17 @@ namespace $ {

if( ! $mol_promise_like( this.cache ) ) return this.cache

await this.cache
await Promise.race([
this.cache,
new Promise( done => {
const sub = new $mol_wire_pub_sub
const prev = sub.track_on()
sub.track_next( this )
sub.track_off( prev )
sub.absorb = done
} )
])
if( ! $mol_promise_like( this.cache ) ) return this.cache

if( this.cursor === $mol_wire_cursor.final ) {
// never ends on destructed fiber
Expand Down

0 comments on commit 686be28

Please sign in to comment.