2023-12-04 18:19:30 +01:00
|
|
|
/* PSEUDO-CODE!!! */
|
|
|
|
import { el, on, scope } from "deka-dom-el";
|
|
|
|
function component(){
|
2023-12-16 16:14:00 +01:00
|
|
|
const { host }= scope;
|
2023-12-04 18:19:30 +01:00
|
|
|
const ul= el("ul");
|
|
|
|
const ac= new AbortController();
|
|
|
|
fetchAPI({ signal: ac.signal }).then(data=> {
|
|
|
|
data.forEach(d=> ul.append(el("li", d)));
|
|
|
|
});
|
2023-12-16 16:14:00 +01:00
|
|
|
host(
|
2023-12-04 18:19:30 +01:00
|
|
|
/* element was remove before data fetched */
|
|
|
|
on.disconnected(()=> ac.abort())
|
|
|
|
);
|
|
|
|
return ul;
|
|
|
|
/**
|
|
|
|
* NEVER EVER!!
|
|
|
|
* let data;
|
|
|
|
* fetchAPI().then(d=> data= O(d));
|
|
|
|
*
|
|
|
|
* OR NEVER EVER!!
|
|
|
|
* const ul= el("ul");
|
|
|
|
* fetchAPI().then(d=> {
|
|
|
|
* const data= O("data");
|
|
|
|
* ul.append(el("li", data));
|
|
|
|
* });
|
2024-11-22 16:26:42 +01:00
|
|
|
*
|
2023-12-04 18:19:30 +01:00
|
|
|
* // THE HOST IS PROBABLY DIFFERENT THAN
|
|
|
|
* // YOU EXPECT AND OBSERVABLES MAY BE
|
|
|
|
* // UNEXPECTEDLY REMOVED!!!
|
|
|
|
* */
|
|
|
|
}
|