{"size": 448, "ext": "js", "max_stars_repo_path": "ui/src/utils/useBlip.js", "max_stars_repo_name": "pankdm/icfpc-2021", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ui/src/utils/useBlip.js", "max_issues_repo_name": "pankdm/icfpc-2021", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ui/src/utils/useBlip.js", "max_forks_repo_name": "pankdm/icfpc-2021", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.3529411765, "max_line_length": 51, "alphanum_fraction": 0.6919642857}
import { useState } from 'react'
import { sleep } from './utils.js'

export default function useBlip(delayMs=1000) {
  const [blipState, setBlipState] = useState(false)
  const [timeoutId, setTimeoutId] = useState(null)
  async function triggerBlip() {
    setBlipState(true)
    clearTimeout(timeoutId)
    setTimeoutId(setTimeout(() => {
      setBlipState(false)
      setTimeoutId(null)
    }, delayMs))
  }
  return [blipState, triggerBlip]
}
