Problem using Observable.combineList of RxJS in Angular












0















I want to use the typscript function to have to Oberservable sync.



First I have a service, which gives me the Oberservable as return.



  public updatePlayers(players: Player): Observable<any>{
return this.http.post(this.REST_URI + "player/updateplayers", players).pipe(
tap(_tap => console.log("Update Players. " + _tap)),
catchError(this.handleError)
)
}


Than I have the function where I want to use the Observable.combineList to wait for booth function to be finished with the update.



OnSubmit(){

let updateAllPlayers = combineLatest(this.restApi.updatePlayers(this.allPlayerTeam1), this.restApi.updatePlayers(this.allPlayerTeam1));
updateAllPlayers.subscribe((teamxx1, teamxx2) => {
this.router.navigate(['statsRecordGrid', this.team1.id, this.team2.id]);
}, (e) => {
console.error("Players not updated");
});

}

....
}


I get this error:




ERROR in players/players.component.ts(91,22): error TS2339: Property
'subscribe' does not exist on type 'OperatorFunction<{}, [{}, any,
any]>'.




Which I do not understand because if I also do the example of RxJs with the timer I geht the same issue.










share|improve this question



























    0















    I want to use the typscript function to have to Oberservable sync.



    First I have a service, which gives me the Oberservable as return.



      public updatePlayers(players: Player): Observable<any>{
    return this.http.post(this.REST_URI + "player/updateplayers", players).pipe(
    tap(_tap => console.log("Update Players. " + _tap)),
    catchError(this.handleError)
    )
    }


    Than I have the function where I want to use the Observable.combineList to wait for booth function to be finished with the update.



    OnSubmit(){

    let updateAllPlayers = combineLatest(this.restApi.updatePlayers(this.allPlayerTeam1), this.restApi.updatePlayers(this.allPlayerTeam1));
    updateAllPlayers.subscribe((teamxx1, teamxx2) => {
    this.router.navigate(['statsRecordGrid', this.team1.id, this.team2.id]);
    }, (e) => {
    console.error("Players not updated");
    });

    }

    ....
    }


    I get this error:




    ERROR in players/players.component.ts(91,22): error TS2339: Property
    'subscribe' does not exist on type 'OperatorFunction<{}, [{}, any,
    any]>'.




    Which I do not understand because if I also do the example of RxJs with the timer I geht the same issue.










    share|improve this question

























      0












      0








      0








      I want to use the typscript function to have to Oberservable sync.



      First I have a service, which gives me the Oberservable as return.



        public updatePlayers(players: Player): Observable<any>{
      return this.http.post(this.REST_URI + "player/updateplayers", players).pipe(
      tap(_tap => console.log("Update Players. " + _tap)),
      catchError(this.handleError)
      )
      }


      Than I have the function where I want to use the Observable.combineList to wait for booth function to be finished with the update.



      OnSubmit(){

      let updateAllPlayers = combineLatest(this.restApi.updatePlayers(this.allPlayerTeam1), this.restApi.updatePlayers(this.allPlayerTeam1));
      updateAllPlayers.subscribe((teamxx1, teamxx2) => {
      this.router.navigate(['statsRecordGrid', this.team1.id, this.team2.id]);
      }, (e) => {
      console.error("Players not updated");
      });

      }

      ....
      }


      I get this error:




      ERROR in players/players.component.ts(91,22): error TS2339: Property
      'subscribe' does not exist on type 'OperatorFunction<{}, [{}, any,
      any]>'.




      Which I do not understand because if I also do the example of RxJs with the timer I geht the same issue.










      share|improve this question














      I want to use the typscript function to have to Oberservable sync.



      First I have a service, which gives me the Oberservable as return.



        public updatePlayers(players: Player): Observable<any>{
      return this.http.post(this.REST_URI + "player/updateplayers", players).pipe(
      tap(_tap => console.log("Update Players. " + _tap)),
      catchError(this.handleError)
      )
      }


      Than I have the function where I want to use the Observable.combineList to wait for booth function to be finished with the update.



      OnSubmit(){

      let updateAllPlayers = combineLatest(this.restApi.updatePlayers(this.allPlayerTeam1), this.restApi.updatePlayers(this.allPlayerTeam1));
      updateAllPlayers.subscribe((teamxx1, teamxx2) => {
      this.router.navigate(['statsRecordGrid', this.team1.id, this.team2.id]);
      }, (e) => {
      console.error("Players not updated");
      });

      }

      ....
      }


      I get this error:




      ERROR in players/players.component.ts(91,22): error TS2339: Property
      'subscribe' does not exist on type 'OperatorFunction<{}, [{}, any,
      any]>'.




      Which I do not understand because if I also do the example of RxJs with the timer I geht the same issue.







      angular typescript angular-ui-router rxjs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 13:00









      M. FishM. Fish

      1172311




      1172311
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You have imported the lettable operator instead of the function. Update the import of combineLatest to be:



          import { combineLatest } from 'rxjs';





          share|improve this answer
























          • Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

            – M. Fish
            Nov 21 '18 at 14:41








          • 1





            Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

            – Teddy Sterne
            Nov 21 '18 at 16:00













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412604%2fproblem-using-observable-combinelist-of-rxjs-in-angular%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You have imported the lettable operator instead of the function. Update the import of combineLatest to be:



          import { combineLatest } from 'rxjs';





          share|improve this answer
























          • Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

            – M. Fish
            Nov 21 '18 at 14:41








          • 1





            Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

            – Teddy Sterne
            Nov 21 '18 at 16:00


















          1














          You have imported the lettable operator instead of the function. Update the import of combineLatest to be:



          import { combineLatest } from 'rxjs';





          share|improve this answer
























          • Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

            – M. Fish
            Nov 21 '18 at 14:41








          • 1





            Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

            – Teddy Sterne
            Nov 21 '18 at 16:00
















          1












          1








          1







          You have imported the lettable operator instead of the function. Update the import of combineLatest to be:



          import { combineLatest } from 'rxjs';





          share|improve this answer













          You have imported the lettable operator instead of the function. Update the import of combineLatest to be:



          import { combineLatest } from 'rxjs';






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 13:07









          Teddy SterneTeddy Sterne

          7,45411831




          7,45411831













          • Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

            – M. Fish
            Nov 21 '18 at 14:41








          • 1





            Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

            – Teddy Sterne
            Nov 21 '18 at 16:00





















          • Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

            – M. Fish
            Nov 21 '18 at 14:41








          • 1





            Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

            – Teddy Sterne
            Nov 21 '18 at 16:00



















          Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

          – M. Fish
          Nov 21 '18 at 14:41







          Create yes I had to imporant it. Now I have this Problem:ERROR in players/players.component.ts(91,32): error TS2345: Argument of type '(teamxx1: any, teamxx2: any) => void' is not assignable to parameter of type '(value: [any, any]) => void'. Okay i think I can only do subscribe( (a) =>..... )

          – M. Fish
          Nov 21 '18 at 14:41






          1




          1





          Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

          – Teddy Sterne
          Nov 21 '18 at 16:00







          Yes combineLatest maps the latest result of each observable to an array of their values in order. Your subscribe will need to be something like this: updateAllPlayers.subscribe(([teamxx1, teamxx2]) => { /* ... */ });

          – Teddy Sterne
          Nov 21 '18 at 16:00






















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412604%2fproblem-using-observable-combinelist-of-rxjs-in-angular%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()