The Composable Architecture (скорочено TCA) - це бібліотека для побудови додатків у послідовному та зрозумілому підході з урахуванням композиції, тестування та ергономіки. Вона може бути в
/// This is a simple Heap implementation which can be used as a priority queue. | |
class Heap<T:Comparable> { | |
typealias HeapComparator<T:Comparable> = (_ l:T,_ r:T) -> Bool | |
var heap = [T]() | |
var count:Int { | |
get { | |
heap.count | |
} | |
} | |
// Copyright © 2023 Alex Kovács. All rights reserved. | |
import ArgumentParser | |
import Foundation | |
import PathKit | |
import XcodeProj | |
// See below for `MainCommand` skeleton. | |
extension MainCommand { | |
struct XcodeCommand: ParsableCommand { |
As Swift evolves, it gains new language features and capabilities. There are different categories of features: some fill in gaps, taking existing syntax that is not permitted and giving it a semantics that fit well with the existing language, with features like conditional conformance or allowing existential values for protocols with Self
or associated type requirements. Others introduce new capabilities or paradigms to the language, such as the addition of concurrency or comprehensive reflection.
There is another large category of language features that provide syntactic sugar to eliminate common boilerplate, taking something that can be written out in long-form and making it more concise. Such features don't technically add any expressive power to the language, because you can always write the long-form version, but their effect can be transformational if it enables use cases that would otherwise have been unwieldy. The synthesis of Codable
conformances, for ex
enum MediaLibrary {} | |
// MARK: - ViewModel | |
extension MediaLibrary { | |
final class ViewModel { | |
let progressCompletionThreshold: Double | |
var zoomPosition: ZoomPosition, | |
assetsCount: Int, | |
_zoomStatus: ZoomType? |
// Author: SwiftUI-Lab (swiftui-lab.com) | |
// Description: Implementation of the showSizes() debugging modifier | |
// blog article: https://swiftui-lab.com/layout-protocol-part-2 | |
import SwiftUI | |
struct MeasureExample: View { | |
var body: some View { | |
VStack { |
// MARK: - TCAView | |
public protocol TCAView: View where Body == WithViewStore<ScopedState, ScopedAction, Content> { | |
associatedtype ViewState | |
associatedtype ViewAction | |
associatedtype ScopedState | |
associatedtype ScopedAction | |
associatedtype Content |
import SwiftUI | |
import Charts | |
import Combine | |
import Foundation | |
final class GameState: ObservableObject { | |
struct Player { | |
var position: Int | |
var halfSize: Int = 150 |
enum AsyncError: Error { | |
case finishedWithoutValue | |
} | |
extension AnyPublisher { | |
func async() async throws -> Output { | |
try await withCheckedThrowingContinuation { continuation in | |
var cancellable: AnyCancellable? | |
var finishedWithoutValue = true | |
cancellable = first() |
extension AnyPublisher { | |
func async() async throws -> Output { | |
try await withCheckedThrowingContinuation { continuation in | |
var cancellable: AnyCancellable? | |
cancellable = first() | |
.sink { result in | |
switch result { | |
case .finished: | |
break |