stackblitz.com/edit/angular-kendo-2grid check with this. If I am clicking next grid it should call new api and display data but it also changes previous data too
I have two different method in my single component which uses .pipe() method and refer to two different method in service file. which means they intended to give different result but give same result.
I am having a view which comes good and i am implement a new view on click on one of the list. I am getting new result fine but exist result updated to new one too.
In my service file:
methodOne(){
return this.http
.get(`https://jsonplaceholder.typicode.com/posts`, this.httpOptions)
.pipe(
map(
res => {
if (!res) {
return res = '';
} else {
return res
}
}
)
)
.pipe(
tap(data => {
this.data = data
})
)
.subscribe(data => {
super.next(data);
});
}
}
Initial First Method Works and Below second works too but When Second Works It changes result of first view too
methodTwo(){
return this.http
.get(`https://jsonplaceholder.typicode.com/newposts`, this.httpOptions)
.pipe(
map(
res => {
if (!res) {
return res = '';
} else {
return res
}
}
)
)
.pipe(
tap(data => {
this.data = data;
})
)
.subscribe(data => {
super.next(data);
});
}
}
In my component file:
comOne(value){
this.editService.methodOne(value);
this.view = this.editService.pipe(map(
data => process(data, this.gridState)
));
}
comTwo(value){
this.editService.methodTwo(value);
this.view2 = this.editService.pipe(map(
data => process(data, this.gridState)
));
}
Both Works but But When I Call comTwo(value) it changes the this.view result too, I want to to persist this.view result
this.editService.methodOne(value);this line does nothing.this.view = this.editService.pipe(map( data => process(data, this.gridState)this line should not work.You can't pipe a service (??). - Roberto ZvjerkovićmethodOne()andmethodTwo()exactly the same except for the url that is called. If they have the same logic it should be just one function with the url as input parameter. Also show the implementation ofthis.editService.pipeif that's a function you wrote! - frido