Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #190 from spring-media/feature/get-rid-of-queue-as…
Browse files Browse the repository at this point in the history
…suming-logic

Get rid of queue hopping
  • Loading branch information
Ivan Lisovyi authored Nov 9, 2020
2 parents a53ffef + 334e585 commit 66765ab
Show file tree
Hide file tree
Showing 117 changed files with 3,295 additions and 3,243 deletions.
38 changes: 38 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# file options

--exclude Carthage,Build,.build,.swiftpm,SourcePackages
--symlinks ignore
--swiftversion 5.3

# format options

--allman false
--binarygrouping 4,8
--commas inline
--comments indent
--decimalgrouping 3,6
--elseposition same-line
--empty void
--exponentcase lowercase
--exponentgrouping disabled
--fractiongrouping disabled
--guardelse same-line
--header ignore
--hexgrouping 4,8
--hexliteralcase uppercase
--ifdef indent
--indent 2
--indentcase false
--importgrouping testable-bottom
--linebreaks lf
--maxwidth none
--octalgrouping 4,8
--patternlet hoist
--operatorfunc spaced
--nospaceoperators ..<, ...
--self remove
--semicolons inline
--stripunusedargs always
--trimwhitespace always
--wraparguments before-first
--wrapcollections before-first
92 changes: 92 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
disabled_rules:
- redundant_string_enum_value
- line_length
- trailing_whitespace
- identifier_name
- opening_brace

opt_in_rules:
- closure_spacing
- conditional_returns_on_newline
- empty_count
- explicit_init
- fatal_error_message
- first_where
- force_unwrapping
- overridden_super_call
- prohibited_super_call
- redundant_nil_coalescing
- operator_usage_whitespace

- array_init
- contains_over_first_not_nil
- joined_default_parameter
- line_length
- literal_expression_end_indentation
- multiline_parameters
- override_in_extension
- pattern_matching_keywords
- redundant_string_enum_value
- sorted_first_last
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call

- nimble_operator
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- single_test_class

# TODO: maybe turn it on one day... (a lot of fixes)
# - closure_end_indentation
# - let_var_whitespace
# - implicitly_unwrapped_optional
# - private_outlet
# - object_literal
# - sorted_imports
# - strict_fileprivate
# - switch_case_on_newline

included:
- Sources
- Tests
- Example

excluded:
- SourcePackages
- .build
- Build
- .swiftpm
- Carthage


cyclomatic_complexity:
warning: 25

type_body_length:
warning: 300
error: 500

file_length:
warning: 500
error: 800

type_name:
min_length: 3
max_length:
warning: 50
error: 60
excluded:
- Id
- Ad

nesting:
type_level:
warning: 3
error: 5

superfluous_disable_command: warning
force_unwrapping: error
trailing_semicolon: error

reporter: "xcode"
6 changes: 3 additions & 3 deletions Example/CarlosMacSample/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Cocoa
import Carlos
import Cocoa
import Combine

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
let cache = CacheProvider.dataCache()

private var cancellables = Set<AnyCancellable>()

func applicationDidFinishLaunching(_ notification: Notification) {
func applicationDidFinishLaunching(_: Notification) {
cache.get(URL(string: "https://github.com/WeltN24/Carlos")!)
.sink(receiveCompletion: { completion in
if case let .failure(error) = completion {
Expand Down
2 changes: 0 additions & 2 deletions Example/CarlosMacSample/ViewController.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Cocoa

class ViewController: NSViewController {

override func viewDidLoad() {
if #available(OSX 10.10, *) {
super.viewDidLoad()
}
}
}

6 changes: 2 additions & 4 deletions Example/CarlosTvSample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
private func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
true
}
}

12 changes: 6 additions & 6 deletions Example/CarlosTvSample/ViewController.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import UIKit
import Carlos
import Combine
import UIKit

class BitcoinResult {
let USDValue: Float

init(USDValue: Float) {
self.USDValue = USDValue
}
}

extension BitcoinResult: ExpensiveObject {
var cost: Int {
return 1
1
}
}

Expand All @@ -22,13 +22,13 @@ enum SampleError: Error {

class ViewController: UIViewController {
private var cancellables = Set<AnyCancellable>()

override func viewDidLoad() {
super.viewDidLoad()

let JSONFetcher: BasicFetcher<URL, AnyObject> = NetworkFetcher().transformValues(JSONTransformer())
let cache = JSONFetcher.transformValues(BTCTransformer())

cache.get(URL(string: "http://coinabul.com/api.php")!)
.sink(receiveCompletion: { completion in
print(completion)
Expand Down
2 changes: 1 addition & 1 deletion Example/CarlosWatchSample Extension/CountryRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import WatchKit
class CountryRow: NSObject {
@IBOutlet var countryName: WKInterfaceLabel!
@IBOutlet var flagImage: WKInterfaceImage!
}
}
3 changes: 1 addition & 2 deletions Example/CarlosWatchSample Extension/ExtensionDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import WatchKit

class ExtensionDelegate: NSObject, WKExtensionDelegate {
func applicationDidFinishLaunching() {
}
func applicationDidFinishLaunching() {}
}
14 changes: 7 additions & 7 deletions Example/CarlosWatchSample Extension/InterfaceController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WatchKit
import Foundation
import WatchKit

import Carlos
import Combine
Expand All @@ -11,11 +11,11 @@ private struct Country {

class InterfaceController: WKInterfaceController {
@IBOutlet var tableView: WKInterfaceTable!

let imageCache = CacheProvider.imageCache()

private var cancellables = Set<AnyCancellable>()

private let countries = [
Country(name: "Italy", flagURL: URL(string: "http://2.bp.blogspot.com/-51ZhmfLCi9s/VBLNUQL-giI/AAAAAAAAAfA/LTayxh5K3C4/s1600/flag_italy_mini.gif")!),
Country(name: "Germany", flagURL: URL(string: "http://www.weezerpedia.com/wiki/images/e/eb/Flag-germany.png")!),
Expand All @@ -30,17 +30,17 @@ class InterfaceController: WKInterfaceController {
Country(name: "Cuba", flagURL: URL(string: "http://flagpedia.net/data/flags/mini/cu.png")!),
Country(name: "UK", flagURL: URL(string: "http://images.smh.com.au/2012/07/18/3464759/Olympic-Flag-Icon_Great_Britain.gif")!)
]

override func awake(withContext context: Any?) {
super.awake(withContext: context)

tableView.setNumberOfRows(countries.count, withRowType: "CountryRow")

for (idx, country) in countries.enumerated() {
if let row = tableView.rowController(at: idx) as? CountryRow {
row.countryName.setText(country.name)
row.flagImage.setImage(UIImage(named: "placeholder"))

imageCache.get(country.flagURL).sink(receiveCompletion: { _ in }) { image in
row.flagImage.setImage(image)
}.store(in: &cancellables)
Expand Down
11 changes: 5 additions & 6 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import UIKit
import Carlos
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
true
}
}

func simpleCache() -> BasicCache<URL, NSData> {
return CacheProvider.dataCache()
CacheProvider.dataCache()
}

func delayedNetworkCache() -> BasicCache<URL, NSData> {
return MemoryCacheLevel().compose(DiskCacheLevel()).compose(DelayedNetworkFetcher())
MemoryCacheLevel().compose(DiskCacheLevel()).compose(DelayedNetworkFetcher())
}
Loading

0 comments on commit 66765ab

Please sign in to comment.