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
project.addDeveloper(jim) // Jim started coding... | |
project.addDeveloper(anna) // Anna started coding... | |
project.stop() | |
jim.stopCoding() | |
anna.stopCoding() // CI stopped. | |
project.addDeveloper(bob) | |
bob.pushCommit("1") | |
jim.pushCommit("2") |
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
project.addDeveloper(jim) // Jim started coding... | |
project.addDeveloper(anna) // Anna started coding... | |
jim.stopCoding() | |
anna.stopCoding() | |
jim.pushCommit("1") | |
project.addDeveloper(bob) // Bob started coding... | |
bob.pushCommit("2") // CI is building Commit(author: "Bob", hash: "2"). |
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
project.addDeveloper(jim) // Jim started coding... | |
project.stop() | |
project.addDeveloper(bob) | |
bob.pushCommit("1") | |
jim.pushCommit("2") // CI is building Commit(author: "Jim", hash: "2"). |
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
project.addDeveloper(jim) // Jim started coding... | |
jim.pushCommit("1") // CI is building Commit(author: "Jim", hash: "1"). | |
project.addDeveloper(anna) // Anna started coding... | |
jim.pushCommit("2") // CI is building Commit(author: "Jim", hash: "2"). | |
anna.pushCommit("3") // CI is building Commit(author: "Anna", hash: "3"). | |
jim.pushCommit("4") // CI is building Commit(author: "Jim", hash: "4"). |
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
let project = Project() | |
let jim = Developer("Jim") | |
let anna = Developer("Anna") | |
let bob = Developer("Bob") | |
let ci = CI() | |
project.developerStream | |
.flatMap { developer -> Observable<Commit> in | |
print("\(developer.name) started coding...") | |
return developer.startCoding() |
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
class Project { | |
private let developerSubject = PublishSubject<Developer>() | |
var developerStream: Observable<Developer> { | |
return developerSubject.asObservable() | |
} | |
func addDeveloper(_ developer: Developer) { | |
developerSubject.onNext(developer) | |
} | |
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
import Foundation | |
// MARK: - Public | |
public struct WebService { | |
let actionManager: ActionManager | |
// As public API, optimize for simplicity by only providing a Result and not throwing. | |
func getProfile(id: String, completion: @escaping (Result<Profile>) -> Void) { | |
let action = Action<NSNull, Profile>(urlString: "api.com/profile", method: "GET", body: NSNull()) |
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
let semaphore = DispatchSemaphore(value: 0) | |
asyncFunction() { result in | |
XCTAssert(result) | |
semaphore.signal | |
} | |
while semaphore.wait(timeout: .now()) == .timedOut { | |
RunLoop.current.run(until: Date(timeIntervalSinceNow: 3)) | |
} |
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
import Foundation | |
protocol HatType { } | |
class Hat: HatType { | |
init() { | |
print("real hat 1") | |
} | |
} |
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
let appDelegateClass: AnyClass? = NSClassFromString("TEST_TARGET_MODULE_NAME.TestAppDelegate") ?? AppDelegate.self | |
let classString = NSStringFromClass(appDelegateClass!) | |
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv) | |
.bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc)) | |
UIApplicationMain(CommandLine.argc, argv, nil, classString) |
NewerOlder