⚒️Thor, the Norseman⚒️ er en bruker på snabeltann.no. Du kan følge dem eller kommunisere med dem hvis du har en konto hvor som helst i fediverset. Hvis du ikke har en konto så kan du registrere deg her.

http.get({}, (res1) => {
...
items.forEach((item) => {
arr[item.id] = item
http.get({}, (subRes) => {
...
subItems.forEach((subItem => {
subArr[subItem.id] = subItem
})
})
})

What's a clean way of creating a single exit point from a construct like this?

@thor If it were Scala, I'd use Futures since they're cleaner syntactically, though I don't know if anyone has created something similar to abstract over time in JS.

@thor
Cleaner than promises. Was basing it on the context of the other post you had

⚒️Thor, the Norseman⚒️

@skypage Whatever I end up using, I probably can't use the data passing mechanism it implements, because I'm populating 3 hash maps with what more or less amounts to 3 relational views of the same data. I wish there was a more elegant way of doing it. At least I maintain data integrity, since all JS objects are assigned by reference.