mirror of https://github.com/sveltejs/svelte
Merge pull request #1150 from sveltejs/gh-1131
prevent await blocks using stale statepull/1153/head
commit
29a156957f
@ -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