Time Relations: とたんに vs なり vs が早いか vs そばから vs 次第
Five patterns all mean "as soon as". They differ in register, in how tightly the two events overlap, and — for そばから — in whether the pattern repeats.
The patterns
とたん(に)
the moment that (most common, neutral)
ドアを開けたとたんに、犬が飛び出してきた。
The moment I opened the door, the dog shot out.
なり
as soon as (written)
彼は家に帰るなり、倒れて寝てしまった。
The instant he got home he collapsed into sleep.
が早いか
no sooner ~ than (written, near-simultaneous)
彼はベルが鳴るが早いか、教室を飛び出した。
No sooner had the bell rung than he bolted from the classroom.
そばから
no sooner ~ than (again and again, usually annoying)
片付けるそばから、子供が散らかす。
No sooner do I tidy up than the kids mess it up again.
次第
as soon as ~ is settled (then immediately)
詳細が分かり次第、ご連絡いたします。
I'll contact you as soon as the details are confirmed.
あげく(に)
after all that trouble, in the end (negative)
長時間迷ったあげくに、何も買わなかった。
After agonising for ages, I ended up buying nothing.
末(に)
after ~ , finally (neutral)
長い議論の末に、結論が出た。
After long discussion, a conclusion was reached.
か〜ないかのうちに
barely had ~ when (the boundary is indistinguishable)
ベルが鳴るか鳴らないかのうちに、生徒たちは教室を飛び出した。
The bell had barely started ringing when the students rushed out.
Decision procedure
Does the pattern happen once, or repeatedly?
Is there a sense of "after much effort/trouble"?
How tight is the overlap, and what register?
Commonly confused
あげく(に) vs 末(に)
Very close in meaning ("after a long process, finally"), but 末に is neutral and objective while あげくに carries weariness and usually a bad result.
そばから vs とたんに
とたんに is a single moment. そばから implies a recurring loop: you do A, B undoes it, over and over.