Is there a way to efficiently handle potentially long computations, such as parsing huge JSON responses, in a non-blocking manner?
I experimented with using the multithread.js library for background work using web workers. However, this library requires passing JSON serializable objects to the execution function, which limits its compatibility with closures and global variables. For example:
MT.process(longRunningJob, doneCallback)(jsonSerializableArgForBGJob)
.
But given that this library hasn't been updated in three years, I am looking for better alternatives that are more suited for Angular2. I need something that can target a wide range of browsers, including older versions (excluding IE/Edge), so service worker-based solutions may not be viable.
In terms of serialization, I came across the cerialize library, which allows for custom object serialization through property decoration. While this could potentially work, it does add complexity and may introduce errors. Additionally, I am concerned about how the library handles inheritance and polymorphism - ideally, I would like a mechanism similar to Java's Serializable interface with overridden serialize/deserialize methods. Is there a way to achieve this in TypeScript/Angular2?