I'm getting resultSelector is no longer supported
when using zip, but I'm not sure how to refactor it according to ngrx 7
this.update.pipe(debounceTime(600),
distinctUntilChanged(),
switchMap(data => {
const { gri, index } = data;
const reqGri = Object.assign({}, gri);
delete reqGri.id;
return zip(
this.dataManager.putGris(gri.id, reqGri),
of(index), resGri => {
return { resGri: resGri[0], index: resGri[1] };
});
})).subscribe((data) => {
this.data[data.index] = data.resGri;
this.dataChange.next([...this.data]);
});
This refactoring should be identical, but now you're using zip without a resultSelector
. All you do is format zip
's result via a map
this.update.pipe(debounceTime(600),
distinctUntilChanged(),
switchMap(data => {
const { gri, index } = data;
const reqGri = Object.assign({}, gri);
delete reqGri.id;
return zip(
this.dataManager.putGris(gri.id, reqGri),
of(index)
).pipe(
map(resGri => ({ resGri: resGri[0], index: resGri[1]}))
);
})
).subscribe(data => {
this.data[data.index] = data.resGri;
this.dataChange.next([...this.data]);
});
or with destructuring to make it a bit cleaner
map(resGri => ({ resGri: resGri[0], index: resGri[1]}))
// can be changed to
map(([resGri, index]) => ({ resGri, index}))