A base for iOS Applications made with ❀️ by Mindera 🀠
Clone or download
p4checo Improve cancellation handling in `NetworkStore`'s (#173)
## Motivation

With the recent resource retry capabilities, the
`URLSessionNetworkStack` fetches now fail with the `.retry` error by
default if a retry policy returns a `.noRetry` action.

This means that if a resource fails with a `URLError.cancelled` error
and a policy handles it returning `.noRetry`, it is not the "vanilla"
`.url(URLErrror.cancelled)` it was before, and instead is a
`.noRetry(_, _, .custom(URLError.cancelled))`.

This difference meant that our `NetworkStore`'s didn't handle these
errors as `.cancelled` as they should.

To make this more robust (i.e. not dependent on `URLError.cancelled`),
the error handling now looks at the `cancellable.isCancelled` flag to
determine if the fetch was in fact cancelled or not. This has the extra
benefit of eliminating the "false positive" cases of fetches that fail
with `URLError.cancelled` because of other reasons (e.g. authentication
challenges failures).

## Changes

- Updated `NetworkStore`'s default `URLSessionNetworkStack` extension
and `NetworkPersistableStore` to return `.cancelled` only when the
network fetch fails and the cancelable has been cancelled.

- Added a `+=` operator on `CancelableBag` to wrap `add`.

- Updated some usages of `CancelableBag.add` to use `+=`

- Improved `MockNetworkStack` to only run the fetch via a new
`runMockFetch` API, to solve timing issues when using the cancelable.
Latest commit b6e310e Nov 12, 2018

README.md

Alicerce πŸ—

from Portuguese:

noun β€’ [ masculine ] /ali’sΙ›ΙΎsΙͺ/

groundwork, foundation, basis

license release platforms Swift 4.2 Carthage CocoaPods SwiftPM Build Status codecov

What is it? πŸ€”

Ever felt that you keep repeating yourself every time you start a new project? That you would like to have all those useful utils and helpers you love already available? We felt that way too! Thus, Alicerce was born. πŸ—

Alicerce is a framework that aims to serve as a starting point for iOS applications, by providing the foundations for many of the common functionalities a modern application requires, as well as be a repository for those small utils and helpers that make our life easier.

It is designed with an MVVM architecture in mind, but you'll find most components are architecture agnostic.

Main features ✨

  1. Analytics πŸ”
  2. Deep Linking πŸ”—
  3. Logging πŸ“
  4. Network 🌍
  5. Persistence πŸ’Ύ
  6. Performance Metrics πŸ“ˆ
  7. Utils βš™οΈ
  8. UI πŸ“²

Documentation πŸ“„

All the documentation can be found in the Documentation folder:

  1. Network
  2. more coming soon...

Examples πŸ‘€

TODO

Installation πŸ”§

Alicerce supports iOS 9.0+ and requires Xcode 10+.

For Xcode 9.3 (Swift 4.0) compatibility, Alicerce 0.3.0 should be used.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add Alicerce to your Podfile:

pod 'Alicerce', '~> 0.4'

Carthage

If you use Carthage to manage your dependencies, simply add Alicerce to your Cartfile:

github "Mindera/Alicerce" ~> 0.4

If you use Carthage to build your dependencies, make sure you have added Alicerce.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.

Swift Package Manager

If you use Swift Package Manager, simply add Alicerce as a dependency of your package in Package.swift:

.Package(url: "https://github.com/Mindera/Alicerce.git", majorVersion: 0, minor: 4),

git Submodule

  1. Add this repository as a submodule.
  2. Drag Alicerce.xcodeproj into your project or workspace.
  3. Link your target against Alicerce.framework.
  4. If linking against an Application target, ensure the framework gets copied into the bundle. If linking against a Framework target, the application linking to it should also include Alicerce.

Setup

Setting up the project for development is simple:

  1. Clone the repository.
  2. Retrieve the project dependencies using one of the following commands from the project root directory:
    • if you have Carthage installed: carthage checkout
    • or: git submodule update --init --recursive
  3. Open Alicerce.xcworkspace
  4. Build Result-iOS scheme
  5. Build Alicerce scheme

Contributing πŸ™Œ

See CONTRIBUTING.

License

Alicerce is Copyright (c) 2016 - 2018 Mindera and is available under the MIT License. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About

With ❀️ from Mindera πŸ€“