Is my code Declarative (RxSwift) ? Please help me to explain why not? I'm newbie in Swift and Rx programming. Is my below code is declarative ? If not, please rewrite it and explain to help me more understanding about declarative :( (my English is so bad)

// MARK: RxSwift
func processPhotoApiService(target: PhotoService) -&gt; Observable&lt;[String: Any]&gt; {
    return RxMoyaProvider&lt;PhotoService&gt;().request(target).map { try $0.mapJSON() as! [String: Any] }
}


.....

ApiServiceManager.shared.processPhotoApiService(target: .getNews(consumerKey: ApiConstants.CONSUMER_KEY, page: 1, imageSize: ApiConstants.MEDIUM_IMG_SIZE))
    .map {
        NewsJson(json: $0)!.photos
    } .flatMap { photos in
        Observable.from(photos).flatMap { photo in
            Observable.from(optional: PhotoItem(name: photo.name, URL: photo.imageUrl, viewCount: photo.viewCount, ratingCount: photo.ratingCount))
        }.toArray()
    }.subscribe { event in
    switch event {
    case .next(let dictionary):
        print("onNext:", dictionary)
        break
    case .error(let error):
        print("onOtherError:", error)
        break
    default:
        break
    }
}
In order for code to be declarative, it must express an invariant. Something that is true throughout the entire life of the variables involved. In other words, a direct chain from input to output. Think Excel. In Excel, every cell in the spreadsheet is either an input variable or a transformation of one or more cells which recursively go back to input variables and that's what makes it declarative. 

Your code is not declarative because it doesn't specify what user action would cause processPhotoApiService to get called.

https://medium.com/@danielt1263/imperative-vs-declarative-programming-a74f6cceff0e