mirror of https://github.com/sveltejs/svelte
prevent await blocks using stale state - fixes #1131
parent
37d5260036
commit
bf25248f9e
@ -0,0 +1,16 @@
|
||||
export default {
|
||||
test(assert, component, target) {
|
||||
const promise = Promise.resolve().then(() => component.set({ answer: 42 }));
|
||||
|
||||
component.set({ promise });
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<p>wait for it...</p>`);
|
||||
|
||||
return promise
|
||||
.then(() => {
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>the answer is 42!</p>
|
||||
`);
|
||||
});
|
||||
}
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
{{#if promise}}
|
||||
{{#await promise}}
|
||||
<p>wait for it...</p>
|
||||
{{then _}}
|
||||
<p>the answer is {{answer}}!</p>
|
||||
{{catch error}}
|
||||
<p>well that's odd</p>
|
||||
{{/await}}
|
||||
{{/if}}
|
Loading…
Reference in new issue