Page 1 of 1

delay REST service using setTimeout()

Posted: Sat Feb 21, 2015 1:39 am
by Ben Walker

I am trying to add some data to a DB. Then, after a set period of time, I'd like that data to delete.

I'm using a create service, and a delete service. Upon success of the create service, I'd like a given period of time to elapse, then I want the delete service to run.

I have mapped the delete service to run at the completion of the create service. I tried inserting some "run JS" (a setTimeout() function) between the two to delay the delete service, but it doesn't seem to work.

Anyone know how I might delay the running of the delete service?

Thanks!


delay REST service using setTimeout()

Posted: Sat Feb 21, 2015 1:49 am
by Bruce Stuart

Ben,

How about this - instead of putting a delay between them - in the success even of the create service just insert this code?:

setTimeout( service_delete.execute({}) , 3000);

that's 3 seconds of delay..... more or less based on your appetite.....

and - also of use in the future at some point will be setInterval ......

of course - put your service name in place of my made up service name...

Best,
Bruce