vadymmarkov / Malibu

:surfer: Malibu is a networking library built on promises
https://vadymmarkov.github.io
Other
414 stars 39 forks source link

Feature: offline cache of requests #49

Closed vadymmarkov closed 8 years ago

vadymmarkov commented 8 years ago

@zenangst @RamonGilabert @onmyway133 💥 Request storage is migrated from https://github.com/hyperoslo/Offline. But it's not just a copy. It adopted to Malibu types and works with promises.

struct GETRequest: GETRequestable {
  var message = Message(resource: "http://hyper.no")
  var storePolicy: StorePolicy = .Offline

  init(parameters: [String: AnyObject] = [:], headers: [String: String] = [:]) {
    message.parameters = parameters
    message.headers = headers
  }
}
networking.replay().done({ result
  print(result)
})

Request storage is networking-specific, and while it replays cached request it will be set to Sync mode. Cached request will go through normal request lifecycle in Malibu, with applied middleware and pre-process operations.

onmyway133 commented 8 years ago

@vadymmarkov just a question, request in offline storage is unique based on its request url?

vadymmarkov commented 8 years ago

@onmyway133 Yes, it is.