javascript - angular2 work in background thread with custom serializable objects -
how achieve this: have potentially long computation (eg. huge json parse http resp.) , want in non-blocking way.
i tried adopt multithread.js lib background work using web worker. lib requires json serializable objects pass execution function not aware of closures, dom or other globals. eg. mt.process(longrunningjob, donecallback)(jsonserializableargforbgjob)
. lib rather old (3 years ago last commit). there better alternatives more suitable angular2? need target widest range of browsers including older ones (except ie/edge) service worker or lib using not option.
for serialization found cerialize lib serialize custom objects decorating props. work adds quite lot of code , seems error prone. other concern use inheritance , polymorphism , not sure if lib ready such uc. 1 expect mechanism known java: serializable interface , overriden serialize/deserialize methods. there way accomplish in typescript/angular2?
take @ vkthread plugin or on angular version ng-vkthread
with plugin can download data directly in thread, process , return result in ui.
doc , live demo vkthread
doc , live demo ng-vkthread
please let me know if have questions.
Comments
Post a Comment