Sleep
util.sleep
is an inflight api.
You cannot sleep in preflight code.
main.w
bring util;
bring cloud;
// util.sleep has inflight api for sleep
inflight () => {
util.sleep(40s);
};
// example showing cloud function that sleeps
let longTask = new cloud.Function(inflight () => {
let timer1 = () => {
log("Time 1 fired");
util.sleep(5s);
};
let timer2 = () => {
log("Time 2 fired");
util.sleep(2s);
};
timer1();
timer2();
});
Wing console output
# Run locally with wing console
wing it
# Run the cloud function using the console (to trigger the inflight function)
Time 1 fired
Time 2 fired