Send across ipc only unique value (#56)

* Send across ipc only unique value

* Fix equality check.

Co-authored-by: Daniel Scalzi <d_scalzi@yahoo.com>
pull/60/head
VolanDeVovan 2020-04-12 03:44:20 +03:00 committed by GitHub
parent 141a753893
commit 9d1aa497a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -14,12 +14,17 @@ console.log('AssetExec Started')
// Temporary for debug purposes.
process.on('unhandledRejection', r => console.log(r))
let percent = 0
function assignListeners(){
tracker.on('validate', (data) => {
process.send({context: 'validate', data})
})
tracker.on('progress', (data, acc, total) => {
process.send({context: 'progress', data, value: acc, total, percent: parseInt((acc/total)*100)})
const currPercent = parseInt((acc/total) * 100)
if (currPercent !== percent) {
percent = currPercent
process.send({context: 'progress', data, value: acc, total, percent})
}
})
tracker.on('complete', (data, ...args) => {
process.send({context: 'complete', data, args})