I have structure returned by API
This is signature
methodApi(): Observable(Array<MyClass>)
This is data
{ id: 1, name: 'Red', parentId: null }
{ id: 2, name: 'Apple', parentId: 1 }
others
I want to group it by parentId
methodApi()
.pipe(groupby((x: MyClass[] => ...))) // THERE
.subscribe(x => console.log(x));
MethodApi return Observable<Array>, in 'groupby' method as input parameter I have array, so I cannot refer to parentId property. When I change input param to MyClass then I get a compilation error.
How to resolve this grouping? I use Angular 9.0 with RxJS 6.5.5