0

I'm using HanekeSwift in order to fetch data stored in cache, when no internet connection is available for my app to call some remote APIs, but I have no properly clear how it works.

I implemented the following function in order to perform this task.

internal func getJsonByString(key: String, completionHandler: (json: Gloss.JSON) -> Void) {
    self.cache.fetch(key: key).onSuccess { json in
        return completionHandler(json: json)
    }
}

I'm wondering how to handle the case in which I do not have the data for which I'm looking for, stored in cache. I think that I have to use the .onFailure method, but in this case, I should also change my completionHandler in order to return also an error.

giograno
  • 1,749
  • 3
  • 18
  • 30

0 Answers0