nitish24p / react-worker-image

React component to fetch image resources via web workers 🤖🤖
MIT License
232 stars 18 forks source link

Limit Workers to max. avail. CPUs #12

Open kurtextrem opened 6 years ago

kurtextrem commented 6 years ago

Fixes #10

nitish24p commented 6 years ago

Each IMageWorker component will now spawn 4 worker threads. As we've removed the worker.terminate call, will those threads still be active when a componentWillUnMount gets called?

nitish24p commented 6 years ago

can you run npm run eslint to see the lint errors and fix those

kurtextrem commented 6 years ago

@nitish24p I fixed the mistakes, sorry for those, I was in a hurry.

kurtextrem commented 6 years ago

There's a big flaw in my current implementation: .onmessage can only exist once it seems. Which means currently ever new instance of ImageWorker replaces the callback function. This means we need something like a Observer pattern.

Edit: I've overlooked, that Workers have the .addEventListener interface too, so that's not a problem anymore.