mirror of https://github.com/sveltejs/svelte
fix reactive updates not reflected when handle promise (#3660)
parent
52c086b1b9
commit
7d9262c421
@ -0,0 +1,13 @@
|
||||
export default {
|
||||
html: `<p>wait for it...</p>`,
|
||||
test({ assert, component, target }) {
|
||||
|
||||
return component.promise
|
||||
.then(() => {
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>the answer is 42!</p>
|
||||
<p>the answer100 is 4200!</p>
|
||||
`);
|
||||
});
|
||||
}
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
let answer = 0;
|
||||
$: answer100 = answer * 100;
|
||||
export let promise = new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
answer = 42;
|
||||
}, 0)
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if promise}
|
||||
{#await promise}
|
||||
<p>wait for it...</p>
|
||||
{:then _}
|
||||
<p>the answer is {answer}!</p>
|
||||
<p>the answer100 is {answer100}!</p>
|
||||
{:catch error}
|
||||
<p>well that's odd</p>
|
||||
{/await}
|
||||
{/if}
|
Loading…
Reference in new issue