Issue
I have the following code :
await this.panelService.getActivePanels().subscribe(activePanels => {
panel = activePanels.find(panel => panel.serviceId === serviceId);
});
I want to add a pipe before the subscribe, that does the find operation, so when I subscribe I will get just the one panel returned by the find, is that possible? and how would it look?
Solution
What you are looking for is called map
and you can use it like this:
this.panelService.getActivePanels().pipe(
map(activePanels => activePanels.find(panel => panel.serviceId === serviceId))
).subscribe(panel => {
console.log(panel);
});
Answered By - Octavian Mărculescu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.