title: Refactor observable to call a NgbModal in a service
body: <p>I have a service in angular 11 that use to call a Ngbmodal component to subscribe when i closed that component. This is the code:</p>
  <pre><code>  showMessage(messageData: MessageDataDTO): Observable&lt;MessageResult&gt; {
      return new Observable((result) =&gt; {
        const dialogRef = this.dialog.open(
          MessageComponent,
          this.ngbModalOptions
        );
        dialogRef.componentInstance.data = messageData;
        dialogRef.closed.subscribe((res) =&gt; {
          result.next(res);
          result.complete();
        });
      });
    }
  </code></pre>
  <p>How could I refactor the code for omit the <code>result.next(res); result.complete();</code>?</p>