title: chain 1 observable result with a stream of observables for a final const
body: <p>I got 5 behaviour subjects in a service, where I collect information from other components to finally combine them in one last object in a <strong>final component</strong>. <strong>My Problem is</strong> I can't get the final object to have every element that is collected. </p>
  
  <p>The detail is that in the first component the user chooses one of two roads to take, so at the <strong>final component</strong> -before I suscribe to everything- I need to see what did the user chose and just consume that observable (<code>forthObsOne or forthObsTwo</code>) and not his non-chosen brother.</p>
  
  <p>my-service.service.ts</p>
  
  <pre><code>private firstObs = new BehaviorSubject(new Class1());
  private secondObs = new BehaviorSubject(new Class2());
  private thirdObs = new BehaviorSubject(new Class5());
  
  //this are the two brother component to be chosen from
  private forthObsOne = new BehaviorSubject(new Class3());
  private forthObsTwo = new BehaviorSubject(new Class3);
  
  // This is the obs for the option component where i choose if
  // i take the forthObsOne or the forthObsTwo road
  private optionObs = new BehaviorSubject(new Class6());
  
  // Now i project those subjects as an observable like the docs recommendation
  firstObs$ = this.firstObs.asObservable();
  secondObs$ = this.secondObs.asObservable();
  thirdObs$ = this.thirdObs.asObservable();
  forthObsOne$ = this.forthObsOne.asObservable();
  forthObsTwo$ = this.forthObsTwo.asObservable();
  optionObs$ = this.optionObs.asObservable();
  
  // Methods for every subject to pass the data from where they are called
  firstObsNext(data: Class1) {
    this.firstObs.next(data)
  } 
  
  secondObsNext(data: Class1) {
    this.secondObs.next(data)
  }
  
  thirdObsNext(data: Class1) {
    this.thirdObs.next(data)
  }
  
  forthObsOneNext(data: Class1) {
    this.forthObsOne.next(data)
  }
  
  forthObsTwoNext(data: Class1) {
    this.forthObsTwo.next(data)
  }
  
  optionObsNext(data: Class1) {
    this.optionObs.next(data)
  }
  
  // The latest thing i tried is with combielatest where i combine 
  // every observable and try to assign the data to a new big object.
  </code></pre>
  
  <p>I've tried first subscribing to <code>optionObs</code> and making and if/else statement to take the <code>forthObsOne</code> or <code>forthObsTwo</code> road. But at the end I got some elements undefined.
  I tried delaying everything with a timeout but i think that's more like a hack and not very professional</p>
  
  <p>At last I tried with <code>combinelatest</code> but failed miserably as I think i'm not understanding it that well (I've watched videos and docs but still can't apply that to this specific problem).</p>
  
  <p>I expect to get a final object with everything I have collected through the components.</p>
  
  <p>I hope it clear enough. Thanks.</p>
  
  <p><strong>UPDATE</strong>
  I'm trying this with the <code>forkJoin</code> approach I've been recommended</p>
  
  <pre><code>let observables1 = [
    this.datosAdminAcumul$,
    this.escalaAcumul$,
    this.seccionesAcumul$,
    this.rubricaUnoAcumul$
  ];
  let observables2 = [
    this.datosAdminAcumul$,
    this.escalaAcumul$,
    this.seccionesAcumul$,
    this.rubricaDosAcumul$
  ];
  
  this.optionObs$.subscribe(option =&gt; {
    if (option == "one") {
      forkJoin(...observables1).subscribe(x =&gt; {
        (data1 = x[0]),
          (data2 = x[1]),
          (data3 = x[2]),
          (data4 = x[3]);
          // i've tried `console.log()` here but it returns me four undefined values
      });
         // i've tried `console.log()` here, same result.
    } else {
      forkJoin(...observables2).subscribe(x =&gt; {
        let pautaFinal = {
          admin: x[0],
          escala: x[1],
          rubrica: x[2],
          secciones: x[3]
        };
      });
  </code></pre>