GianlucaGuarini / icaro

Smart and efficient javascript object observer, ideal for batching DOM updates (~1kb)
MIT License
573 stars 29 forks source link

listen method doesn't work inside a web worker #17

Open W4G1 opened 4 years ago

W4G1 commented 4 years ago

Try to run this snipped inside a web worker:

let obj = icaro({})

obj.listen(function () {
  console.log('Something changed!')
})

obj.foo = 'bar'

It will result in this error and the listener function never gets triggered:

TypeError: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': No function was found that matched the signature provided.
    at registerImmediate (set-immediate.js?f31a:66)
    at setImmediate (set-immediate.js?f31a:15)
    at Object.eval (index.js?74c6:112)
    at Object.set (index.js?74c6:75)