angular material how to show spinner during an synchronous intensive task -


i want show spinner during execution of synchronous task. set showspinner = true before task starts , showspinner=false after finishes. however, spinner doesn't show. think because expensive task block dom update *nfif="showspinner shows spinner. how fix this? thinking of using lifecycle hooks not sure how to.

updateimagedata() {     if (this.cropsizechanged) {         this.showspinner = true;         var imgdata = this.cropper.getcroppedcanvas().todataurl(); //**expensive**         this.editedimage = imgdata;         this.cropsizechanged = false;         this.showspinner = false;     }     console.log("updated imagedata");     if(this.istaggableimage) {         settimeout(() => {this.croppedimageboundingrect = this.croppedimageref.nativeelement.getboundingclientrect();}, 100);     }  } 

the reason why spinner not showing setting false straight away after making expensive call. can try 2 following things

  1. if expensive call returns callback or promise should set false in call back. in nagular use observable therefore place set this.showspinner = false inside subscribe.
  2. try code below

    public updateimagedata(){ this.showspinner = true; urthing.expensivecall() settimeout()=>{ this.showspinner = false; },3000); }


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -