Skip to content

Commit

Permalink
support preonchange for watchers (#151)
Browse files Browse the repository at this point in the history
* support preonchange for watchers

* just auto flush instead
  • Loading branch information
mafintosh authored May 3, 2024
1 parent 549a449 commit fb8d7a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ class Watcher extends ReadyResource {
this._eager = !!opts.eager
this._updateOnce = !!opts.updateOnce
this._onchange = opts.onchange || null
this._flush = opts.flush !== false && this.core.isAutobase

this.on('newListener', autoFlowOnUpdate)

Expand Down Expand Up @@ -1295,6 +1296,7 @@ class Watcher extends ReadyResource {
await this.bee.update({ wait: true })
}

if (this._flush) await this.core.base.flush()
if (this.closing) return { value: undefined, done: true }

await this._closePrevious()
Expand Down

0 comments on commit fb8d7a5

Please sign in to comment.