Page 1 of 1

Delay between functions

Posted: Sat Oct 25, 2014 9:39 am
by David wyatt

Hi,

On a button click i have a list of javascripts running in order. What i need is for there to be a delay between 2 of them. ive tried adding a run javascript with following text

window.setTimeout(Functionwait, 1000);
function functionwait() {
}
but is just stops the list commands at this point and doesnt execute any others after.

thanks Image


Delay between functions

Posted: Sat Oct 25, 2014 5:01 pm
by Alena Prykhodko

Hello,

You can write all code on one click event, then time out should work as expected.


Delay between functions

Posted: Tue Oct 28, 2014 11:40 am
by Maryna Brodina

Hello!

You invoke all handlers on the same event. It would be better to join them in one code and invoke with delay as you specified using setTimeout for each function. Or if you want to guarantee functions execution sequence, use callbacks:
prefunction foo(params, callback){
// do stuff with params

// move on to next step
callback(params)
}

function bar(params, callback){
// do stuff with params

// move on to next step
callback(params)
}/pre


Delay between functions

Posted: Tue Oct 28, 2014 11:43 am
by David wyatt

Hi,

thanks Maryna, works great now.

thank you


Delay between functions

Posted: Tue Jun 23, 2015 8:44 pm
by umama fakher

only first function is executing second is not executing ?


Delay between functions

Posted: Tue Jun 23, 2015 9:17 pm
by umama fakher

I am using your code like this. I want the database service executed than the mailto window open and then it navigates to start page alerting the success.
Am I using your code correctly?
pre
function foo(params, callback){
databaseService.execute({});
window.open('mailto:someone@example.com?subject=any&body=any');

callback(params);
}
function bar(params,callback){
window.open('mailto:someone@example.com?subject=any&body=any');
Apperyio.navigateTo('StartPage', {});

callback(params);
}
/pre


Delay between functions

Posted: Wed Jun 24, 2015 3:53 am
by Yurii Orishchuk

Hi Umana,

You don't need such technique.

So the solution is:

1 On first service "Success" event add "Run javascript" event handler.

2 Populate it with following js code:

pre

Code: Select all

 window.open('mailto:someone@example.com?subject=any&body=any');  

 Apperyio.navigateTo('StartPage', {}); 

/pre

Regards.


Delay between functions

Posted: Fri Jun 26, 2015 6:01 am
by umama fakher

Thankyou so much. This is working. Cheers Appery.io team :) !!