Created
February 16, 2021 12:46
-
-
Save AntonGorelov/458862dc8d903a8eff0839c5a72a5422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private _initSelectedPeople(): void { | |
// this._targetStateService.getAllPeople() | |
// .pipe(takeUntil(this._destroyed$)) | |
// .subscribe((allPeople: TargetModel[]) => { | |
// | |
// console.log(allPeople, 'allpeople'); | |
// | |
// let ids = []; | |
// this._activatedRoute.queryParamMap | |
// .pipe(take(1)) | |
// .subscribe((params: ParamMap) => { | |
// ids = params.getAll('people'); | |
// }); | |
// | |
// const selectedPeople = allPeople.filter((person: TargetModel) => { | |
// return ids | |
// .some((personId: string) => { | |
// return person.id === personId; | |
// }); | |
// }); | |
// | |
// this._targetStateService.setSelectedPeople(selectedPeople); | |
// }); | |
combineLatest([this._targetStateService.getAllPeople(), this._getParams$()]) | |
.pipe(takeUntil(this._destroyed$)) | |
.subscribe((value: [TargetModel[], ParamMap]) => { | |
const allPeople = value[0]; | |
const peopleIds = value[1].getAll('people'); | |
console.log(allPeople, peopleIds); | |
const selectedPeople = allPeople.filter((person: TargetModel) => { | |
return peopleIds | |
.some((personId: string) => { | |
return person.id === personId; | |
}); | |
}); | |
this._targetStateService.setSelectedPeople(selectedPeople); | |
}); | |
} | |
private _getParams$(): Observable<ParamMap> { | |
return this._activatedRoute.queryParamMap | |
.pipe( | |
take(1) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment