Run a function whenever a Photon loses its WiFi connection and re-establishes it


Is there any way to run a function whenever the Photon has to (and has) re-established its WiFi Connection after a drop out? Most reliable way to do this? Would be really helpful. I occasionally miss cloud publish subscribe messages because they’re sent (or not received) when the device is momentarily offline. If there was a way to say:
"Hi, I’ve been offline, please resend, and by the way, I wanted to send this, but couldn’t, because I was offline"
it would be great!



You can either poll WiFi.ready() or you subscribe to a system event