Call a function once or repeatedly after some time