Files
canine/app/javascript/controllers/refresh_turbo_frame_controller.js
2025-01-27 21:12:58 -08:00

20 lines
397 B
JavaScript

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = {
frequency: Number
}
connect() {
this.refreshInterval = setInterval(() => {
this.element.setAttribute("src", window.location.href);
}, this.frequencyValue)
}
disconnect() {
if (this.refreshInterval) {
clearInterval(this.refreshInterval)
}
}
}