The tutorial/documentation should have an example of calling a function inside an each block to do some additional processing. This is non-intuitive so putting it in the tutorial would be very helpful.
e.g.
<script>
function dosomething(item) {
var dict = {};
// Put original object into the dictionary
dict.item = item;
// Do some processing and put various results in the dictionary to be used in the loop.
dict.result = "success";
dict.count = 12;
return dict;
}
</script>
{#each list as item}
{#each [dosomething(item)] as val}
<div>{val.result} {val.item} {val.count}</div>
{/each}
{/each}
Is there a reason to do it that way instead of just
{#each list.map(dosomething) as val}
<div>{val.result} {val.item} {val.count}</div>
{/each}
Here's a REPL example of this style: https://svelte.dev/repl/3d071e514c7641c580980c48dd1b6665?version=3.14.0
Sure but it's not in the TUTORIAL.
Most helpful comment
Is there a reason to do it that way instead of just
Here's a REPL example of this style: https://svelte.dev/repl/3d071e514c7641c580980c48dd1b6665?version=3.14.0