programandoarg/pg_rails

View on GitHub
pg_layout/app/javascript/controllers/clear_timeout_controller.js

Summary

Maintainability
A
0 mins
Test Coverage
import { Controller } from '@hotwired/stimulus'

// Connects to data-controller="clear-timeout"
export default class extends Controller {
  connect () {
    this.element.dataset.timeoutId.split(',').forEach((el) => {
      const timeoutId = parseInt(el)
      clearTimeout(timeoutId)
      console.log(`clearedTimeout: ${timeoutId}`)
    })
    this.element.remove()
  }
}