ThunderRequest v2.0 Release Notes

Release Date: 2019-05-16 // almost 5 years ago
  • 👍 In this version ThunderRequest has been completely re-written in Swift! This will allow us to continue to continue to support this framework moving forward as we work exclusively in Swift at 3SidedCube.

    💥 Breaking Changes

    🔨 During this re-write we also took the decision to refactor some of the API which has introduced some breaking changes.

    • Individual GET, POST e.t.c. functions have been replaced with a single request function which takes an enum representation of the HTTP method. There is a much wider array of parameters available to this function now.

      // REMOVED! requestController.get("path") { (response, error) in

      }

      // NEW SYNTAX! requestController.request("path", method: .GET) { (response, error) in

      }

    • Request body is no longer of type Any it's of type RequestBody which is a protocol. Standard implementations such as JSONRequestBody and FormURLEncodedRequestBody e.t.c. are provided out of the box.

      requestController.request("users", method: .POST, body: JSONRequestBody(user.dictionaryRepresentation)) { (response, error) in

      }

    • 🚚 The TSC prefix has been removed from all classes.

    • 🚚 TSCErrorRecoveryAttempter overrides have been moved to a ErrorOverrides struct.

      // REMOVED! TSCErrorRecoveryAttempter.registerOverrideDescription("We're having some trouble getting your location. Please check that you have location services enabled.", forDomain: kCLErrorDomain, code: CLError.locationUnknown.rawValue)

      // NEW SYNTAX! ErrorOverrides.register(overrideDescription: "We're having some trouble getting your location. Please check that you have location services enabled.".localised(with: "_GENERAL_ERROR_CLERROR_UNKNOWN"), recoverySuggestion: nil, forDomain: kCLErrorDomain, code: CLError.locationUnknown.rawValue)

    • Other minor breaking changes (re-naming of variables and method signatures e.t.c.)

    🆕 New Features

    We also took the time to add some nice new features!

    • 👍 Full support for Codable!

      // Encodable request body! requestController.request("users", method: .POST, body: EncodableRequestBody(user, encoding: .json)) { (response, error) in

      } // Decodable request response! requestController.request("users", method: .GET) { (response, error) in guard let _response = response else { return } let user: User? = _response.decoded() }

    • 👌 Support for xml and binary plist request type

      requestController.request("users", method: .POST, body: PropertyListRequestBody(user, format: .binary)) { (response, error) in

      }

    • Cleaner and easier MultipartForm API