FredrikSandell / angular-workers

MIT License
69 stars 25 forks source link

Question: Is it possible? #2

Open MaestroJurko opened 9 years ago

MaestroJurko commented 9 years ago

Question:

I am a bit new to web workers, so maybe this is a stupid question.

I would like to use web worker when angularjs is creating html of data. I have a table, and I use ngRepeat=”tableData”, is it possible to use this lib, for when tableData changes, that processing and appending of the table is done in a web worker?

Is that even possible to do with web workers?

FredrikSandell commented 9 years ago

Hi,

It is not a stupid question:) You can use this library to process the data but not to insert it in the table. The web workers have no access to the DOM and are therefore unable to directly manipulate it. You would need to pass the processed data back to the main thread before inserting it in the table. You need to carefully consider if it is worth using web workers for this. Transferring data from or to a web worker (usually) means copying the data, which can be a somewhat expensive operation if it is a large amount of data. If the processing of the information that you need to insert in the table is CPU intensive and if the resulting processed data is really small this library is a good option.

/Fredrik

MaestroJurko commented 9 years ago

There is no processing of data, what backends send we display, the problem is, that when we have larger amount of columns in the table, the digest cycle takes longer, and that is what I would like to speed up.

So what I read from your comment, this is not possible to do with web workers.

MaestroJurko commented 9 years ago

http://bahmutov.calepin.co/run-angular-digest-cycle-in-web-worker.html

maybe it is?

FredrikSandell commented 9 years ago

That could possibly work. I also know that frameworks like Famous have been able to synchronize CPU intensive operation with the digest cycle. Would it be possible for you to draw on that concept? Chunking the data and loading the data one part at a time, allowing the digest cycle to run in between data loads?

MaestroJurko commented 9 years ago

$digest cycle is slow when scrolling, when loading it is ok, but scrolling is the problem.

pulkitsinghal commented 9 years ago

@mato75 - would limiting watchers to only the data you're viewing when scrolling help? http://kamilkp.github.io/angular-vs-repeat/

MaestroJurko commented 9 years ago

@pulkitsinghal I am using this library, and it is to slow. I would like to combine angular-vs-repeat and watchers.

pulkitsinghal commented 9 years ago

By this you mean you're already using angular-vs-repeat ? BTW you can reach me for chat on gitter.im

MaestroJurko commented 9 years ago

Yes already using angular-vs-repeat.

https://gitter.im/mato75

New to gitter.im