im attempting to use vue-worker to offload a task that processes an selected input file to base64, to a background thread.However i'm having no success. Here is what I am attempting:
// file is selected file from input
const getBase64 = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => resolve(reader.result)
reader.onerror = error => reject(error)
})
}
this.$worker.run((file, getBase64) => {
getBase64(file).then((data) => {
return data
})
}, [file, getBase64])
.then(result => {
console.log(result)
})
.catch(e => {
console.error(e)
})
However I get the following error:
DOMException: Failed to execute 'postMessage' on 'Worker': function getBase64(file) { return new Promise(function (resolve, reject) { var reader = new FileReader();...... } could not be cloned.
What exactly does this error relate to & is what I'm trying accomplish possible?