title: RxSwift: onDisposed activated before Alamofire return data
body: <p>I'm trying to get the JSON data from REST (swift 2.3) with rxSwift and Alamofire. This is my code:</p>
  
  <pre><code>  func getArticles(articlesReq: ArticlesReq) - &gt; Observable &lt; [Article] &gt; {
        return Observable &lt; [Article] &gt; .create {
            observer in
                let request = Alamofire.request(.POST, apiPath, parameters: DataHelper().convertStringToDictionary(JSONString), encoding: .JSON)
                    .responseArray {
                        (response: Response &lt; [Article], NSError &gt; ) in
                            if let articlesArray = response.result.value {
                                observer.on(.Next(articlesArray))
                            }
                            observer.on(.Completed)
                    }
            return AnonymousDisposable {
                request.cancel()
            }
  
        }
  
    }
  
    getArticles(articlesReq).observeOn(MainScheduler.instance)
        .subscribe(
            onNext: {
                data in
                print(data)
            },
            onError: {
                error in
                print(error)
            },
            onCompleted: {
                print("Completed")
            },
            onDisposed: {
                print("Disposed")
            }
        ).addDisposableTo(db)
  </code></pre>
  
  <p>onDisposed return data before Alamofire.request return data (onNext, onError, onCompleted not return data ). How to wait for a response?  </p>