Could I say
for "when I was coming home"?
If you use the adjectival '的', then it has to be '当我回家的时候' (at the time I come home) - 时候(time/ moment) is a noun
If you don't use the adjectival '的' then you can write '当我回家时' (when I come home) - 时 (when) is an adverb
当我回家的时候 = at the time I come home
当我回家时 = when I come home
当我正在回家的时候 = during the time I was coming home
当我正在回家时 = when I was coming home
当我回家的时候 is OK
You can also do this without an explicit 'when'.
I saw a fox when I was coming home. 我看到一条狐狸，在我回家的路上。
When I was coming home, I saw a fox. 我在回家的路上看到一条狐狸。
I find it is not so easy to move things around in Chinese sentences.