{{#await}} blocks with previously-resolved promises should skip to `then`
In a case like this, it would be nice if we could bypass the pending stage:
{{#if foo}}
{{#await alreadyFulfilled}}
<p>this will be rendered initially when foo becomes true</p>
{{then}}
<p>then this will immediately replace it</p>
{{catch}}
<!-- ... -->
{{/await}}
{{/if}}
I'm too lazy to test this right now but I think that the way promises work, the user won't see any flashing. But it's still wasteful. Perhaps the await block could do something grotesque like this:
promise.then(value => {
promise.__value = value;
}, error => {
promise.__error = error;
});
Made a REPL to test it, you're correct it gets called but you don't see it.
https://svelte.technology/repl?version=1.54.1&gist=4d4b2fa27ea365d94032c0221e14de3f
This situation feels like it's calling out for a WeakMap to act as a central lookup for already-resolved promises. But I don't know whether it's worth it if we have to implement this two ways, for with and without legacy: true.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I want to give a +1 to this feature
Wow, old issue, but yeah would still be nice. Updated REPL as syntax has changed
https://svelte.dev/repl/5a592e5cbb0d4142ace9787f11bf77e2?version=3.59.1
closing in favour of #8459