Skip to content

Commit

Permalink
$mol_wire_fiber: step api
Browse files Browse the repository at this point in the history
  • Loading branch information
jin committed Nov 5, 2023
1 parent c48f155 commit dabf7fd
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions wire/fiber/fiber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,7 @@ namespace $ {

if( ! $mol_promise_like( this.cache ) ) return 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
} )
])
await Promise.race([ this.cache, this.step() ])
if( ! $mol_promise_like( this.cache ) ) return this.cache

if( this.cursor === $mol_wire_cursor.final ) {
Expand All @@ -286,6 +277,19 @@ namespace $ {

}

step() {
return new Promise< null >( done => {
const sub = new $mol_wire_pub_sub
const prev = sub.track_on()
sub.track_next( this )
sub.track_off( prev )
sub.absorb = ()=> {
done( null )
sub.destructor()
}
} )
}

}

}

0 comments on commit dabf7fd

Please sign in to comment.