Skip to content

Commit eaae817

Browse files
committed
fix(ember): await message-box btn2 before close
Mirror async safety: await btn2Callback via RSVP, log errors, close in finally with destroy guards to avoid races and unhandled rejections.
1 parent f9e6d64 commit eaae817

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

app/components/message-box.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,18 @@ export default Ember.Component.extend({
4040
},
4141

4242
btn2Click() {
43-
if (this.btn2Callback) {
44-
this.btn2Callback();
45-
}
46-
this.close();
43+
Ember.RSVP.resolve()
44+
.then(() => (this.btn2Callback ? this.btn2Callback() : undefined))
45+
.catch(e => {
46+
if (Ember.Logger && Ember.Logger.warn) {
47+
Ember.Logger.warn("message-box btn2Callback", e);
48+
}
49+
})
50+
.then(() => {
51+
if (!this.isDestroyed && !this.isDestroying) {
52+
this.close();
53+
}
54+
});
4755
},
4856

4957
closeModal() {

0 commit comments

Comments
 (0)