Skip to content

Commit

Permalink
Simply defer pause to idle
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Nov 20, 2023
1 parent d9f8958 commit 256a683
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,9 @@ const view = new Int32Array(handle.buffer, handle.byteOffset + binding.offsetofT
binding.init(handle, ontimer)

Bare
.on('suspend', onsuspend)
.on('idle', onidle)
.on('resume', onresume)
.on('exit', onexit)

function onsuspend () {
if (refs) binding.unref(handle)
}

function onidle () {
pause()
}

function onresume () {
if (refs) binding.ref(handle)
resume()
}

function onexit () {
destroy()
}
.on('idle', pause)
.on('resume', resume)
.on('exit', destroy)

let refs = 0
let garbage = 0
Expand Down

0 comments on commit 256a683

Please sign in to comment.