Add a wait function to the api.