Invoke a function after transition or immediately.