title: How to await inside RxJS subscribe method
body: <p>Inside of an RxJS subject's subscribe callback, I want to <code>await</code> on an <code>async</code> function. Below is a code example which the typescript transpiler complains about saying: </p>
  
  <blockquote>
    <p>Error:(131, 21) TS2304:Cannot find name 'await'.</p>
  </blockquote>
  
  <pre><code>async ngOnInit() {
    this.subscriber = dateSubscription.subscribe((date: Date) =&gt; {
      let dbKey = await this._someService.saveToDatabase(someObject);
      // wait for db write to finish before evaluating the next code
      // ... some other code here
    });
  }
  </code></pre>
  
  <p>Usually I see this when trying to call await inside a non <code>async</code> function. Do I somehow need to make the subscribe callback <code>async</code> or am I going about this wrong? The function <code>saveToDatabase</code> is <code>async</code> and returns a promise resolving to the database primary key that was written to.</p>