This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FOAttributedStringBuilder.swift | |
// | |
// Created by Fernando Ortiz on 18/11/15. | |
// Copyright © 2015 Fernando Ortiz. All rights reserved. | |
// | |
import Foundation | |
class FOAttributedStringBuilder { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Dequeuable.swift | |
// | |
// Created by Fernando Ortiz on 9/30/16. | |
// Copyright © 2016 Fernando Martín Ortiz. All rights reserved. | |
// | |
import UIKit | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Registrable.swift | |
// | |
// Created by Fernando Ortiz on 9/30/16. | |
// Copyright © 2016 Fernando Martín Ortiz. All rights reserved. | |
// | |
import UIKit | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DogsTableViewDriver.swift | |
// MediumSamples | |
// | |
// Created by Fernando Ortiz on 1/3/17. | |
// Copyright © 2017 Fernando Martín Ortiz. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DogsViewController.swift | |
// MediumSamples | |
// | |
// Created by Fernando Ortiz on 1/3/17. | |
// Copyright © 2017 Fernando Martín Ortiz. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SampleViewController.swift | |
// MediumSamples | |
// | |
// Created by Fernando Ortiz on 1/4/17. | |
// Copyright © 2017 Fernando Martín Ortiz. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppDelegate.swift | |
// MediumSamples | |
// | |
// Created by Fernando Ortiz on 1/3/17. | |
// Copyright © 2017 Fernando Martín Ortiz. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the async side... | |
func someAsyncFunction(completion: @escaping (Error?) -> Void) { | |
// Something that takes some time to complete. | |
completion(nil) // Or completion(SomeError.veryBadError) | |
} | |
// In the consumer side... | |
someAsyncFunction { error in | |
if let error = error { | |
print("Oops! Something went wrong...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
someAsyncFunction { | |
anotherAsyncFunction1 { | |
anotherAsyncFunction2 { | |
anotherAsyncFunction3 { | |
anotherAsyncFunction4 { | |
// Thanks to God this has no error handling 😰 | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getUser(withID id: Int) -> Future<User> { | |
return Future { completion in | |
// Here you call an API | |
// that returns the user you are looking for. | |
APIClient.get(getUserURL(id: id)) { user in | |
completion(.success(user)) | |
} | |
} | |
} |
OlderNewer