developit / workerize

🏗️ Run a module in a Web Worker.
https://github.com/developit/workerize-loader
4.35k stars 91 forks source link

React native support? #2

Closed xzilja closed 6 years ago

xzilja commented 6 years ago

Hi, wanted to check if there are any difficulties when using workerize with react native? There are solutions that achieve it i.e https://github.com/austinksmith/Hamsters.js But as always your api is much cleaner and minimal.

developit commented 6 years ago

It should work with react-native-workers:

import { Worker } from 'react-native-workers'
import workerize from 'workerize'
window.Worker = Worker
workerize( () => {
  export function foo() {
    return 1
  }
})
xzilja commented 6 years ago

Thank you, quickly tested this and seems to be working good.