The time countdown tool provides a countdown queue function, avoids opening multiple timers, and supports clearing a single countdown task. More efficient countdown.
npm install @oasis-cloud/countdown
- Add countdown task
import countdown from '@oasis-cloud/countdown'
const [clearCountdown, addCountdown] = countdown()
const taskName = 'skill'
const taskParams = {
remaining: 1000,
unit: 'sec'
}
const task = (remaining) => {
// do something
console.log(remaining)
}
addCountdown(taskName, taskParams, task)
- Clear countdown
// Only clears skill tasks
clearCountdown('skill')
// clear all tasks
clearCountdown()