As Soon As (The Moment That)
8 related grammar points that express the same core idea - compared below so you can tell which one to reach for.
Members
か〜ないかのうちに / 次第
Promising to do something the moment a condition is met.
~次第 vs ~か~ないかのうちに: Use 次第: 決まり次第ご連絡します. It attaches to a ます-stem and points forward to something you will do, so it fits business commitments. か〜ないかのうちに narrates two events almost overlapping and cannot carry a promise.
The second thing happened so fast it caught you out.
~たかと思ったら vs ~か~ないかのうちに: Use たかと思ったら. It carries the speaker's surprise at the reversal (泣いたかと思ったら笑っている). か〜ないかのうちに reports the tight timing neutrally, with no reaction attached.
なり / や否や / たが最後
Literary narration: one action followed instantly on another.
Verbる なり vs Verb たが最後: Use なり. It reports immediate succession in written narrative (帰るなり寝てしまった). たが最後 is not about speed: it says that once the first thing happens there is no undoing it, and the consequence is usually bad.
Choosing between the two literary 'no sooner than' forms.
Verbる や否や vs Verbる なり: や否や and なり are close enough that either will pass in most written narration. や否や is the stiffer and more bookish of the two; なり is slightly freer, and is the one that also turns up in older colloquial writing.