Pass datatables to webworker.
Pass datatables to webworker.
pmengo
Posts: 74Questions: 37Answers: 2
I have a problem to use datatables instance inside a web worker. How can i pass raw object instead of type API ?
if i use the _API resulting from the instance i get 'Converting circular structure to JSON' Error
This discussion has been closed.
Answers
You will not be able to do that. The problem that you are seeing is because web workers make copies of what you pass them by serialization. Functions inside an object generate that error (I learned the hard way) when you attempt to serialize them.
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
i know... but must be a way to do it
Use the
toArray()
method to convert from a DataTables API instance to a plain array - e.g.:Allan
Thanks Allan. The problem is when there is 50k records , this is a expensive operation blocking the UI for long time...
Is there a way to set the data without obj.tbl.rows.add(obj['backupAllData']) ?
Like obj.tbl.data=alldata ? what about aadata?
It will take a finite amount of time of course - but all it does is a
slice
so it should be fairly quick.data()
androws().data()
are the public API methods to get the data for the table.Allan