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
#!/usr/bin/env swift | |
print("Hello World!") |
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
#!/bin/sh | |
echo "Hello World!" |
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
#!/bin/sh | |
echo "Hello World!" |
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 routes(_ app: Application) throws { | |
try HealthCheckController().register(with: app.routes) | |
} |
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 | |
import Vapor | |
class HealthCheckController { | |
/// Returns the word 'Success' to indicate that the service is up and running. | |
func healthCheck(_ request: Request) throws -> Response { | |
return Response(status: .ok, headers: [:], body: "Success") | |
} | |
} |
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
protocol ViewModel { | |
func viewDidAppear() | |
func viewDidDisappear() | |
} | |
class SimpleViewModel: ViewModel { | |
private var cancellables = Set<AnyCancellable>() | |
private var previousBrightness: Double? | |
private let screenBrightnessService: ScreenBrightnessService | |
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
protocol ScreenBrightnessService3 { | |
var publisher: ScreenBrightnessPublisher { get } | |
func set(to value: Double) | |
} | |
class UIKitScreenBrightnessService3: ScreenBrightnessService3 { | |
private let brightnessSubject: CurrentValueSubject<Double, Never> | |
private var cancellables = Set<AnyCancellable>() | |
var publisher: ScreenBrightnessPublisher { // i.e. AnyPublisher<Double, Never> | |
brightnessSubject.eraseToAnyPublisher() |
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
protocol ScreenBrightness: AnyObject { | |
var brightness: CGFloat { get set } | |
} | |
extension UIScreen: ScreenBrightness {} | |
protocol ScreenBrightnessService2 { | |
var publisher: ScreenBrightnessPublisher { get } | |
func set(to value: Double) | |
} |
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
protocol ScreenBrightness: AnyObject { | |
var brightness: CGFloat { get set } | |
} | |
extension UIScreen: ScreenBrightness {} | |
protocol ScreenBrightnessService2 { | |
var publisher: ScreenBrightnessPublisher { get } | |
func set(to value: Double) | |
} |
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
typealias ScreenBrightnessPublisher = AnyPublisher<Double, Never> | |
protocol ScreenBrightnessService1 { | |
var publisher: ScreenBrightnessPublisher { get } | |
} | |
class UIKitScreenBrightnessService1: ScreenBrightnessService1 { | |
let publisher: ScreenBrightnessPublisher // i.e. AnyPublisher<Double, Never> | |
init() { |
NewerOlder