Problem using Observable.combineList of RxJS in Angular
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
add a comment |
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
add a comment |
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
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
angular typescript angular-ui-router rxjs
asked Nov 21 '18 at 13:00
M. FishM. Fish
1172311
1172311
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You have imported the lettable operator instead of the function. Update the import of combineLatest
to be:
import { combineLatest } from 'rxjs';
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You have imported the lettable operator instead of the function. Update the import of combineLatest
to be:
import { combineLatest } from 'rxjs';
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
add a comment |
You have imported the lettable operator instead of the function. Update the import of combineLatest
to be:
import { combineLatest } from 'rxjs';
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
add a comment |
You have imported the lettable operator instead of the function. Update the import of combineLatest
to be:
import { combineLatest } from 'rxjs';
You have imported the lettable operator instead of the function. Update the import of combineLatest
to be:
import { combineLatest } from 'rxjs';
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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