Using system thread will make it so wifi connecting is not blocking.
https://docs.particle.io/reference/firmware/photon/#system-thread
The code I posted does not block when connecting to wifi. D7
still blinks until you are connected to the cloud and the 15 second callback is reached.
I know there is probably a better way of doing this, so my code is not really perfect.