title: Call a method synchronously
body: <p>I want to use a dialog to get the confirmation of a user. The dialog window works fine and the console.log drops the right value of the dialog. My question is how to handle it in the calling method. In line 2 you can see the subscription of the method. This is how I expected to do it but it drops the error &quot;TS2339: Property 'subscribe' does not exist on type 'void'.&quot; I want to call the method synchronously, thats why I want to use the subscription.
  Do you have an idea how I can realize the method call correctly?</p>
  <p>(I can't perform the action in the openDialog method because I want to reuse it for the other functions)</p>
  <pre><code> deleteAll() {
      this.openDialog('Title', 'You really want to do it?').subscribe( result =&gt; {
        if(result === true) do something;
      });
    }
  
  
    private openDialog(title: string, message: string) {
      const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
        data: {
          message: message,
          buttonText: {
            ok: 'Ok',
            cancel: 'Cancel'
          }
        }
      });
      dialogRef.afterClosed().subscribe(result =&gt; {
        console.log(result);
        return result;
      });
    }
  </code></pre>