-
When using a dialog and producing an error in a switchMapped something (like API call), it is closing afterwards. This is some kind of new behavior, as it was not like this in the past as far as I remember. Why is that happening? And how can I prevent that? Here an example: openDialog() {
this.dialogs
.open(this.myTemplate, {
size: 's',
})
.pipe(
switchMap(() => {
throw new Error('Damn!');
}),
// This will not close it
// switchMap(() => {
// return of('Hello!');
// }),
)
.subscribe({
next: result => console.log('next', result),
error: result => console.log('error', result),
complete: () => console.log('complete'),
});
} And in template: <button tuiButton size="m" appearance="outline" (click)="context.$implicit.complete()">
<span translate>GENERAL.CANCEL</span>
</button>
<button
tuiButton
type="button"
size="m"
(click)="context.$implicit.next()"
>
<span translate>GENERAL.DELETE</span>
</button> And a Stackblitz to try it out: https://stackblitz.com/edit/angular-r7kgfe |
Beta Was this translation helpful? Give feedback.
Answered by
waterplea
Nov 22, 2023
Replies: 1 comment
-
This part hasn't change for a very long time. Dialogs are closed once the stream completes. Your error terminates the stream so that is expected. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
splincode
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This part hasn't change for a very long time. Dialogs are closed once the stream completes. Your error terminates the stream so that is expected.