timer

let timer_id = timer_start({time}, {callback}, [, {options}])

{time}是等待的时间

{callback}是回调函数

{options}是一个字典类型的选项:

  • “repeat”: callback重复的次数,如果是-1会无限重复,如果没有提供值,则会重复1次
func MyHandler(timer)
  echo 'Handler called'
endfunc

let timer = timer_start(500, 'MyHandler',
	\ {'repeat': 3})

其他函数

timer_stop({timer_id})

timer_stopall()

timer_info([{timer_id}])

timer_pause({timer_id}, {paused})