The Composable Architecture(TCA)๋ ์ผ๊ด๋๊ณ ์ดํดํ ์ ์๋ ๋ฐฉ์์ผ๋ก ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค๊ธฐ ์ํด ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋๋ค. ํฉ์ฑ(Composition), ํ ์คํ (Testing) ๊ทธ๋ฆฌ๊ณ ์ธ์ฒด ๊ณตํ(Ergonomics)์ ์ผ๋์ ๋ TCA๋ SwiftUI, UIKit์ ์ง์ํ๋ฉฐ ๋ชจ๋ ์ ํ ํ๋ซํผ(iOS, macOS, tvOS, watchOS)์์ ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
๐ฆ
This file contains hidden or 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
| extension Publisher { | |
| func coolDown<S: Scheduler>(for cooltime: S.SchedulerTimeType.Stride, | |
| scheduler: S) -> some Publisher<Self.Output, Self.Failure> { | |
| return self.receive(on: scheduler) | |
| .scan((S.SchedulerTimeType?.none, Self.Output?.none)) { | |
| let eventTime = scheduler.now | |
| let minimumTolerance = scheduler.minimumTolerance | |
| guard let lastSentTime = $0.0 else { | |
| return (eventTime, $1) | |
| } |
This file contains hidden or 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
| public struct DictionaryStorageMacro: MemberMacro { | |
| public static func expansion(of node: AttributeSyntax, | |
| providingMembersOf declaration: some DeclGroupSyntax, | |
| in context: some MacroExpansionContext | |
| ) throws -> [DeclSyntax] { | |
| let stringIdentifier = SimpleTypeIdentifierSyntax(name: .identifier("String")) | |
| let anyIdentifier = SimpleTypeIdentifierSyntax(name: .keyword(.Any)) | |
| let dictionarySyntax = DictionaryTypeSyntax(leftSquareBracket: .leftSquareBracketToken(), | |
| keyType: stringIdentifier, |
This file contains hidden or 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 | |
| final class FileIO { | |
| private let buffer:[UInt8] | |
| private var index: Int = 0 | |
| init(fileHandle: FileHandle = FileHandle.standardInput) { | |
| buffer = Array(try! fileHandle.readToEnd()!)+[UInt8(0)] // ์ธ๋ฑ์ค ๋ฒ์ ๋์ด๊ฐ๋ ๊ฒ ๋ฐฉ์ง |
This file contains hidden or 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/bash | |
| # move project dir | |
| PROJECT_HOME=`pwd` | |
| echo "cd $PROJECT_HOME" > /tmp/tmp.sh | |
| # pod init & update | |
| echo "pod update" >> /tmp/tmp.sh | |
| chmod +x /tmp/tmp.sh |
This file contains hidden or 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/bash | |
| # move project dir | |
| PROJECT_HOME=`pwd` | |
| echo "cd $PROJECT_HOME" > /tmp/tmp.sh | |
| # search .xcodeproj file and strip filename | |
| PROJECT_NAME="" | |
| for f in *.xcodeproj; do | |
| PROJECT_NAME="${f%.*}" |
This file contains hidden or 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
| { | |
| "categories": [ | |
| { | |
| "name": "Movies", | |
| "videos": [ | |
| { | |
| "description": "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
| "sources": [ | |
| "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" | |
| ], |
This file contains hidden or 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
| // You have a very very large video file you need to upload to a server while your app is backgrounded. | |
| // Solve by using URLSession background functionality. I will here use Alamofire to enable multipart upload. | |
| class Networking { | |
| static let sharedInstance = Networking() | |
| public var sessionManager: Alamofire.SessionManager // most of your web service clients will call through sessionManager | |
| public var backgroundSessionManager: Alamofire.SessionManager // your web services you intend to keep running when the system backgrounds your app will use this | |
| private init() { | |
| self.sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default) | |
| self.backgroundSessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.background(withIdentifier: "com.lava.app.backgroundtransfer")) |