Execute Background Task In Javascript

后端 未结 9 1600
迷失自我
迷失自我 2020-11-28 22:39

I have a cpu intensive task that I need to run on the client. Ideally, I\'d like to be able to invoke the function and trigger progress events using jquery so I can update

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 23:34

    I had a similar problem to solve recently where i needed to keep my UI thread free while crunching some data to display.

    I wrote a library Background.js to handle a few scenarios: a sequential background queue (based on the WorkerQueue library), a list of jobs where each is called on every timer, and an array iterator to help break up your work into smaller chunks. Examples and code here: https://github.com/kmalakoff/background

    Enjoy!

提交回复
热议问题