Closed shlomiassaf closed 7 years ago
Thanks a lot @shlomiassaf. So sorry, I'm a bit lost, how do you refactor this?
openDetailModal(event) {
event.preventDefault();
const dialog = this.modal.open(BuyerCRMDetailModalComponent, overlayConfigFactory({buyer: this.buyer}, BSModalContext));
dialog.then(resultPromise => {
return resultPromise.result
.then(
result => {
this.log.info('openDetailModal()', 'then', result);
if (!result) return;
this.log.info('do something with', result);
},
() => {
this.log.info('openDetailModal()', 'Rejected');
});
});
}
Looking at the code change i guess :
openDetailModal(event) {
event.preventDefault();
const dialog = this.modal.open(BuyerCRMDetailModalComponent, overlayConfigFactory({buyer: this.buyer}, BSModalContext));
dialog.then(
result => {
this.log.info('openDetailModal()', 'then', result);
if (!result) return;
this.log.info('do something with', result);
},
() => {
this.log.info('openDetailModal()', 'Rejected');
});
}
@Gbacc Thanks for helping out!
The code you put is almost working though we need to call result
on dialog
:
...
dialog.result.then(
...
BREAKING CHANGE: Calling
modal.open()
returned a Promise ofDialogRef
. The async operation is not required and exists due to legacy angular implementation of dynamic components.modal.open()
now returns theDialogRef
instance and NOT thePromise
.You need to refactor your codebase to accomodate this change, this is a big change and it is required to remove the complexity working with
DialogRef
.Plugin authoers:
Maybe
type does not exists anymore. If you retuned the dialog instance from yourModal
implementations there is not much to refactor other then types here and there.If you return
Promise
ofDialogRef
you will have to refactor your code.