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 | |
/// Serial queue that executes added operations asynchronosly, one at a time. | |
/// | |
/// Example usage: | |
/// ```swift | |
/// let queue = AsyncSerialQueue() | |
/// for number in 1...100_000 { | |
/// queue.addOperation { | |
/// let task = Task { print(number) } |
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 ComposableArchitecture | |
import Foundation | |
@Reducer | |
public struct AsyncSequenceReducer<Element, Failure>: Sendable | |
where Element: Sendable, | |
Element: Equatable, | |
Failure: Sendable, | |
Failure: Error | |
{ |
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 ConcurrencyExtras | |
import struct Foundation.UUID | |
@dynamicMemberLookup | |
final class LockIsolatedValueStream<Value>: Sendable where Value: Sendable { | |
init(_ value: Value) { | |
self._lock = LockIsolated(value) | |
} | |
var value: Value { _lock.value } |
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 ComposableArchitecture | |
import Foundation | |
@Reducer | |
struct AsyncStreamReducer<Element> | |
where Element: Sendable, | |
Element: Equatable | |
{ | |
struct State: Equatable { | |
let id = UUID() |
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
#!/usr/bin/env bash | |
# Measure time | |
# Usage: stopwatch [start|stop|print] | |
function stopwatch { | |
case "$1" in | |
start) | |
# start new stopwatch | |
STOPWATCH+=($(date -u +%s)) | |
;; |
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 CryptoKit | |
import Dependencies | |
import Foundation | |
import XCTestDynamicOverlay | |
public struct GravatarJSON: Equatable, Sendable, Codable { | |
public init(entry: [Entry]) { | |
self.entry = entry | |
} |
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 ComposableArchitecture | |
import Logging | |
extension _ReducerPrinter { | |
/// Logs info about received actions and state changes to swift-log's Logger with provided label. | |
/// | |
/// Example usage: | |
/// ``` | |
/// let store = Store(initialState: AppFeature.State()) { | |
/// AppFeature()._printChanges(.swiftLog(label: "tca")) |
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 ComposableArchitecture | |
import SwiftUI | |
struct Parent: Reducer { | |
struct State: Equatable { | |
@PresentationState var child: Child.State? | |
} | |
enum Action: Equatable { | |
case presentChildButtonTapped |
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
/// MIT License | |
/// | |
/// Copyright (c) 2023 Dariusz Rybicki Darrarski | |
/// | |
/// Permission is hereby granted, free of charge, to any person obtaining a copy | |
/// of this software and associated documentation files (the "Software"), to deal | |
/// in the Software without restriction, including without limitation the rights | |
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
/// copies of the Software, and to permit persons to whom the Software is | |
/// furnished to do so, subject to the following conditions: |
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 | |
@dynamicMemberLookup | |
public actor CurrentValueAsyncSequence<Value>: AsyncSequence where Value: Sendable { | |
public typealias Element = Value | |
public init(_ value: Value) { | |
self.value = value | |
} |
NewerOlder