Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker blob url example #80

Open
zerozoo-a opened this issue Sep 18, 2023 · 0 comments
Open

worker blob url example #80

zerozoo-a opened this issue Sep 18, 2023 · 0 comments

Comments

@zerozoo-a
Copy link
Owner

브라우저의 대기 탭에선 에러가 발생 할 수 있습니다.

const createWorker = (f)=>{
    const code = f.toString();
    // console.log('code', code)
    const blob = new Blob([`(${code})()`])
    // console.log('blob', blob)
    return new Worker(URL.createObjectURL(blob))
}

const workForWorker = () => {
    self.addEventListener('message', e => {
        console.log('my name is ', e.data)

        postMessage(e.data)
    })
}

const worker = createWorker(workForWorker);
worker.postMessage('zerozoo');
// my name is zerozoo
@zerozoo-a zerozoo-a changed the title singlefile worker for frontend worker blob url example Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant