Calling native flashlight time delay

When trying to switch the native flashlight with single button if button is pressed two times before light gets on it hangs all the app. Is there any need to set delays please tell how?
Thanks

setTimeout would be helpful for that.

You can insert setTimeout(() => { }, 200)
inside your function.
so it’s going to be look like:

yourFunction() { 

this.firstnativeFunction();

  setTimeout(() => {
   this.secondnativeFunction()
  }, 3000)

}

Your first native function will start immediately and then your second native function will fire 3000 milliseconds later… which is 3 seconds.

Thanks but could please share for flashlight not to wait for calling immediately or toggle flashlight fast or what should be the minimum time delay for flashlight in ionic native to call on and off
regards

Both on and off return a Promise. Just code up the click handler so a click does nothing if a Promise has been initiated but not resolved. Different devices are going to have different wait times. Wait for the ack, not fora fixed amount of time.

Nice looking technique, however i tried disabling click on button as
<button (click)=“offlight()” [disabled]=“disabled”>
setting disabled=true then turned is false again in the success callback of native light off function.
but the problem remains same it still stop every thing if double click is pressed quickly.

this.disabled = true;
this.flashlight.switchOff().then(()=>{
this.disabled=false;
});

promiseDispatched: boolean = false;

clickhandler() {
  If (this.promiseDispatched) do nothing
  else {
   this.promiseDispatched = true;
   return turnOnOrOffWhichEverOneYoureHandling().then(_ => this.promiseDispatched=false);
  }
}