Per Ready, emphasis mine:
First, you decide what perceivable circumstance will trigger your reaction. Then, you choose the action you will take in response to that trigger, or you choose to move up to your speed in response to it. [...] When the trigger occurs, you can either take your reaction right after the trigger finishes or ignore the trigger. Remember that you can take only one reaction per round.
The trigger completes before your Reaction activates.
The distances are irrelevant and unneededly specific. Fireball or arrow, you can say "when I'm targeted with a ________". As soon as the attacker lets fly, the fact that you're the target becomes a "perceivable circumstance" and your Ready triggers.
However, if you are trying to ready a spell, there are other concerns:
When you ready a spell, you cast it as normal but hold its energy, which you release with your reaction when the trigger occurs. To be readied, a spell must have a casting time of 1 action, and holding onto the spell's magic requires concentration. If your concentration is broken, the spell dissipates without taking effect.
If the trigger never occurs, you can't release the held spell. You're concentrating on it until you cast it. That prevents you from casting other concentration spells. This also ends any spell on which you are currently concentrating.
To do so, you can take the Ready action on your turn, which lets you act using your reaction before the start of your next turn
You're now in the position of having cast a spell, burned a spell slot, and possibly having no effect of the spell if the trigger doesn't occur.