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.
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.
this is the ts
export class ExerciseTestsComponent implements OnInit {
  exercises: Observable<any>
  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 => {
        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 =>
      this.exerciseForm.addControl(control.prefix, this.fb.control(""))
    );
  }
 
    