title: How to use take(1) in Angular 6?
body: <p>Can someone please illustrate the syntax for take(1) in Angular 6 / rxjs 6?</p>
  
  <p>In the code below, I retrieve a document from Firestore and then make it available as an observable.  </p>
  
  <p>I then subscribe to that observable, read the timestamp of the document, and format the age in human-readable format.  That works great, however it does not need to execute every time there are changes in the document stream.  It only needs to execute one time, since the document timestamp is never, ever going to change.</p>
  
  <p>How can I modify this code to incorporate <code>take(1)</code>, so that the age string is only generated once and the subscription to <code>items</code> is not kept open?  I cannot find any clear example of the syntax for <code>take(1)</code> under Angular / rxjs version 6.  All of the examples I can find are for previous versions.</p>
  
  <pre><code>import { Component, Input, OnChanges } from '@angular/core';
  import { AngularFirestore, AngularFirestoreDocument } from 'angularfire2/firestore';
  import { Item } from '../../interfaces/item';
  
  @Component({
    selector: 'app-item',
    templateUrl: './item.component.html',
    styleUrls: ['./item.component.scss']
  })
  export class ItemComponent implements OnChanges {
  
    @Input() itemId: string;
    private itemDoc: AngularFirestoreDocument&lt;Item&gt;;
    public item: Observable&lt;Item&gt;;
    public age: string;
  
    constructor(private afs: AngularFirestore) {}
  
    ngOnChanges() {
  
      if ( this.itemId ) {
  
        this.itemDoc = this.afs.doc&lt;Item&gt;('items/' + this.itemId);
        this.item = this.itemDoc.valueChanges();
  
        this.item.subscribe(thisitem =&gt; {
          this.age = Utils.getFormattedAgeString(thisitem.timestamp);
        });
  
      }
  
    }
  
  }
  </code></pre>