[Vuejs]-Vue component/element creating while method is working

1👍

Is it possible to creating component or html elements when method is working?

Its not possible in JavaScript using synchronous code. JavaScript is single-threaded and even browser rendering is blocked when your synchronous/long running code is executing, not to mention Vue logic which re-renders your template and updates the DOM (really recommend this talk – explains the problem beautifully)

You have basically two options:

  1. Split up you workload into smaller chunks, process only one at a time and use setTimeout(nextBatch, 0) to schedule “next chunk” processing. See this SO question for more details…
  2. You can offload your computation to WebWorker which is running in its own thread but brings new challenges (for example data between your Vue app and Web Worker need to be serialized/deserialized on both sides)

Leave a comment