I'm working with a no-so user-friendly API using Angular HTTP and rxjs. I'm trying to get return an Observable<List<Object>>
from my service. Here's a sample of the JSON that's returned from my get request:
Items: {
"$type": "System.Collections.Generic.List`1[[Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts]], mscorlib"
"$values": [
Object { "$type": "Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts", EntityTypeName: "7", Properties: {…} }
Object { "$type": "Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts", EntityTypeName: "7", Properties: {…} }
Object { "$type": "Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts", EntityTypeName: "7", Properties: {…} }
]
}
And then inside each Object:
{
"$type": "Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts"
EntityTypeName: "7"
Properties: {
"$type": "Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts"
"$values": {}
}
I need to extract out $values
for each item, and then return a list of the $values
objects. But I can't figure out how to do that with Angular and rxjs without subscribing. And I don't want to subscribe, as I want the component, not the service, to process the resulting data.
I've been looking in rxjs Operators as a solution to my problem. But there doesn't seem to be an operator that converts a List<X>
into X while preserving the Observable.
Is this possible to do with Angular2+ and rxjs? Or is there maybe a better way to accomplish this task. I'm relatively new to reactive programming, so any general advice would be appreciated.