mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-17 00:51:49 +00:00
feat: poder cancelar cuando se está haciendo un fetch
si salimos de la página hay que poder cancelar todos los fetchs pendientes sin producir errores
This commit is contained in:
parent
5f53abe78a
commit
255ea763b4
1 changed files with 3 additions and 2 deletions
|
@ -103,6 +103,8 @@ export default class extends Controller {
|
|||
this.currentTarget.innerHTML = "";
|
||||
this.originalValue = [];
|
||||
|
||||
const signal = window.abortController?.signal;
|
||||
|
||||
for (const itemTarget of this.itemTargets) {
|
||||
if (!itemTarget.dataset.value) continue;
|
||||
if (!this.isChecked(itemTarget)) continue;
|
||||
|
@ -114,8 +116,7 @@ export default class extends Controller {
|
|||
|
||||
this.currentTarget.appendChild(placeholder);
|
||||
|
||||
// TODO: Renderizarlas todas juntas
|
||||
fetch(this.newArrayValueURL)
|
||||
fetch(this.newArrayValueURL, { signal })
|
||||
.then((response) => response.text())
|
||||
.then((body) => {
|
||||
const template = document.createElement("template");
|
||||
|
|
Loading…
Reference in a new issue