RxSwift request for each iteration of array
<p>I'm using RxSwift to fetch some network data and I'm having trouble with performing a request for each iteration of an array. This was my idea:</p>

<ul>
<li>I have an API endpoint that returns an array of Objs which doesn't contain location data. Then I would loop through the array of Objs and for each get the location details with the Obj id. Something like this:</li>
</ul>

<p>(code simplified)</p>

<pre><code>var arrayObj = networkClient.request(getObjsEndpoint)
        .fetchObjLocationDetails(withNetworkClient: networkClient)
</code></pre>

<ul>
<li>And the fetchObjLocationDetails() would be something like:</li>
</ul>

<p>(code simplified)</p>

<pre><code>extension ObservableType where E == [Obj]? {
func fetchObjsLocationDetails(withNetworkClient networkClient: NetworkClient) -&gt; Observable&lt;[Obj]?&gt; {
        return flatMap { Objs -&gt; Observable&lt;[Obj]?&gt; in
            guard let unwrappedObjs = Objs as [Obj]? else { return Observable.just(nil) }

            let disposeBag = DisposeBag()
            var populatedObjs = [Obj]()

            unwrappedObjs.forEach { obj in
                let getLocationDetailsEndpoint = WeDriveParkAPI.getLocation(id: String(obj.id))

                networkClient.request(getLocationDetailsEndpoint)
                    .observeOn(MainScheduler.instance)
                    .subscribe(onNext: { json in
                        guard let populatedObj = Obj.fromJSON(json) as Obj? else { return }

                        populatedObjs += [populatedObj]
                        }, onError:{ e in

                    }).addDisposableTo(disposeBag)
            }
            return Observable.just(populatedObjs)
        }
    }
}
</code></pre>

<p>This solution is not really working because the code doesn't even go inside the subscribe next closure.</p>

<p>Please have in mind I'm new to both Swift and RxSwift programming so be gentle :) Any help would be greatly appreciated.</p>