Moved onFlush invocation to end of trigger in connection.

Signed-off-by: Jakob Brandsborg Ehmsen <jakobehmsen.github@gmail.com>