2022-12-15 04:00:54 +00:00
|
|
|
---
|
|
|
|
title: Interface hilbish.timers
|
|
|
|
description: timeout and interval API
|
|
|
|
layout: doc
|
|
|
|
menu:
|
|
|
|
docs:
|
|
|
|
parent: "API"
|
|
|
|
---
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
The timers interface si one to easily set timeouts and intervals
|
|
|
|
to run functions after a certain time or repeatedly without using
|
|
|
|
odd tricks.
|
|
|
|
|
2022-12-21 01:00:31 +00:00
|
|
|
## Interface fields
|
|
|
|
- `INTERVAL`: Constant for an interval timer type
|
|
|
|
- `TIMEOUT`: Constant for a timeout timer type
|
|
|
|
|
2022-12-15 04:00:54 +00:00
|
|
|
## Object properties
|
|
|
|
- `type`: What type of timer it is
|
|
|
|
- `running`: If the timer is running
|
|
|
|
- `duration`: The duration in milliseconds that the timer will run
|
|
|
|
|
|
|
|
## Functions
|
|
|
|
### start()
|
|
|
|
Starts a timer.
|
|
|
|
|
|
|
|
### stop()
|
|
|
|
Stops a timer.
|
|
|
|
|
|
|
|
### create(type, time, callback)
|
|
|
|
Creates a timer that runs based on the specified `time` in milliseconds.
|
2022-12-21 01:00:31 +00:00
|
|
|
The `type` can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT`
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2022-12-21 01:00:31 +00:00
|
|
|
### get(id) -> timer (Timer/Table)
|
2022-12-15 04:00:54 +00:00
|
|
|
Retrieves a timer via its ID.
|
|
|
|
|