title: Returning data from Observables in Angular
body: <p>I'm trying to perform operations with data coming from Firestore. I'm subscribing to an observable using valuechanges() and trying to extract an array of objects so I can create a form based on it.</p>
  
  <p>It's my second time using rxjs and I've tried everything I know but couldn't make it happen. I can console.log my desired array inside the subscription but can't return it so I can use it outside. </p>
  
  <p>this is the ts</p>
  
  <pre><code>export class ExerciseTestsComponent implements OnInit {
    exercises: Observable&lt;any&gt;
    exerciseForm: FormGroup;
    isAnswered: boolean; 
    isCorrect: boolean; 
    helloThere: []
  
  
    constructor(
      private fb: FormBuilder,
      private db: AngularFirestore) {}
  
    ngOnInit(): void {
      let exerciseTest; 
      this.db
      .collection('availableExercises')
      // .doc("xvXCAxUrj4842ItZCyrv")
      // .collection("questions")
      .valueChanges()
      .subscribe(
        res =&gt; {
          console.log(res);   
        }
        )
      console.log("below is exerciseTest ")
      console.log(exerciseTest)
      this.createGroup()
    }
  
    createGroup() {
      console.log("below is my firestore data")
      console.log(this.exercises)
      this.exerciseForm = this.fb.group({});
      this.exercises[0]
      .doc("xvXCAxUrj4842ItZCyrv")
      .collection("questions")
      .forEach(control =&gt;
        this.exerciseForm.addControl(control.prefix, this.fb.control(""))
      );
    }
  </code></pre>