Skip to content

Dota hero characters and their stats. In this project i have use Moya for api work with ReactiveRx, Kingfisher for loading Images, SkeletonView for shimmer and Reusable for simple working.

License

Notifications You must be signed in to change notification settings

Dr-Groot/DotaHeros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DotaHeros

appstore

Dota hero characters and their stats. In this project i have use Moya for api work with ReactiveRx, Kingfisher for loading Images, SkeletonView for shimmer and Reusable for simple working.

MyPods:

  • pod 'Alamofire'
  • pod 'Moya/RxSwift'
  • pod 'RxSwift'
  • pod 'RxCocoa'
  • pod 'Kingfisher'
  • pod 'SkeletonView'
  • pod 'Reusable'
  • pod 'NVActivityIndicatorView', '~> 4.8.0'

Simulator Screen Shot - iPhone 11 - 2023-02-17 at 11 06 09

Simulator Screen Shot - iPhone 11 - 2023-02-17 at 11 06 20

TIP (How to manage data and best way to call api using Moya)

import Foundation
import Moya

class NetworkManager {

    static let shared: NetworkManager = NetworkManager()

    let provider = MoyaProvider<Service>()

    func callAPI(forEntity service: Service, completion: @escaping (Bool, String, HERO?) -> Void) {
        provider.request(service) { result in
            switch result {
            case let .success(response):
                let decoder = JSONDecoder()
                let arrData = try! decoder.decode(HERO.self, from: response.data)
                completion(true, "Success", arrData)
            case .failure:
                completion(false, "Failure", nil)
            }
        }
    }
}
import Foundation

class ViewModel {
    
    var mainData: HERO?
    
    func getData(completion: @escaping (Bool, String) -> Void) {
        NetworkManager.shared.callAPI(forEntity: .heroStats) { [weak self] isSuccess, message, resultData in
            guard let self = self else { return }
            if isSuccess {
                self.mainData = resultData
                print(message)
            } else {
                print(message)
            }
            completion(isSuccess, message)
        }
    }
}

About

Dota hero characters and their stats. In this project i have use Moya for api work with ReactiveRx, Kingfisher for loading Images, SkeletonView for shimmer and Reusable for simple working.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages