mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-20 01:11:48 +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.currentTarget.innerHTML = "";
|
||||||
this.originalValue = [];
|
this.originalValue = [];
|
||||||
|
|
||||||
|
const signal = window.abortController?.signal;
|
||||||
|
|
||||||
for (const itemTarget of this.itemTargets) {
|
for (const itemTarget of this.itemTargets) {
|
||||||
if (!itemTarget.dataset.value) continue;
|
if (!itemTarget.dataset.value) continue;
|
||||||
if (!this.isChecked(itemTarget)) continue;
|
if (!this.isChecked(itemTarget)) continue;
|
||||||
|
@ -114,8 +116,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
this.currentTarget.appendChild(placeholder);
|
this.currentTarget.appendChild(placeholder);
|
||||||
|
|
||||||
// TODO: Renderizarlas todas juntas
|
fetch(this.newArrayValueURL, { signal })
|
||||||
fetch(this.newArrayValueURL)
|
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((body) => {
|
.then((body) => {
|
||||||
const template = document.createElement("template");
|
const template = document.createElement("template");
|
||||||
|
|
Loading…
Reference in a new issue