2

I am developing a hybrid application using cordova. I have added ionic loading indicator for one activity. But I have observed that ionic loading indicator stops spinning when the code execution enters in a file which is a pure javascript file.

If you have any solution to make it spin while the code execution is in the pure Javascript file please let me know.

Any suggestions will be appreciated. Thank you in advance.

Chetan Purohit
  • 364
  • 1
  • 3
  • 16

1 Answers1

1

What is that raw javascript file does?

My guess is that you're probably doing a request and waiting for it synchronously. So it's normal that the spin freeze. You have to make your request asynchronous.

If it's doing something else that take a lot of time you may use multiple call to setTimeout([function],0); so your browser won't freeze.

EDIT : Add the link from my comment : Javascript async loop processing

Community
  • 1
  • 1
Walfrat
  • 5,363
  • 1
  • 16
  • 35
  • Thank you for your suggestion. Let me try it out. – Chetan Purohit Feb 09 '16 at 10:30
  • So what do you have in your raw js file ? a long process or a synchronous request ? it will be easier if i know what it is. – Walfrat Feb 09 '16 at 11:01
  • It is a synchronous request. Actually I am generating a PDF file using jsPDF and that javascript file contains many function related to it and these all functions are called synchronously. It takes around 5 seconds to execute. – Chetan Purohit Feb 09 '16 at 11:46
  • So it's not a server request. The only way to make it "asynchronous-like" is the trick with setTimeout(fn,0). Check the accepted answer there http://stackoverflow.com/questions/9772400/javascript-async-loop-processing – Walfrat Feb 09 '16 at 12:32