Non-blocking delay, then do something. Is there a way?

Im trying to figure out how to pass 'evt' data from an event handler to another a handler function after a delay.
This wont work: runIn(60, myHandler(evt)) because cant use parentheses in a runIn
This runIn(60, myHandler, [data:evt]) throws error java.lang.StackOverflowError: null (onTimeHandler)

With out a runIn delay calling this works fine as expected: myHandler(evt) Data is passed.

Is there another way to call a non-blocking delay then pass evt data to a function?
Something like this.. delay then myHandler(evt)

Not an expert here but I think myHandler should be a string (would need quotation marks).

runIn(60, "myHandler", [data:evt])

Checked that, doesnt't work, still stackOverflow.

This works but I need more data the just the descriptionText. I want deviceId and value passed also.
runIn(60, myHandler, [data:evt.descriptionText])
Is the full evt array to much data for a runIn data pass?

Could it be barfing at evt being an object? Try converting it to a json string and then parse it in your handler function.

1 Like

The documentation explains this fairly well, IMHO.

You need to pass a MAP of the data you want passed to the Method.

3 Likes

Ok, after messing around with a Map finally got it working.
evtMap = [value:evt.value, deviceId:evt.deviceId, descriptionText:evt.descriptionText]
if (pushDelay) { runIn(60, mytHandler, [data:evtMap]) }

On the other side in myHander(data) I can grab the mapped data. Example:
pushDevice.deviceNotification("App: ${app.label} -- $data.descriptionText")

1 Like