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 SwiftUI | |
import WebKit | |
#if os(macOS) | |
public typealias ViewRepresentable = NSViewRepresentable | |
#elseif os(iOS) | |
public typealias ViewRepresentable = UIViewRepresentable | |
#endif | |
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 SwiftUI | |
import WebKit | |
#if os(macOS) | |
public typealias ViewRepresentable = NSViewRepresentable | |
#elseif os(iOS) | |
public typealias ViewRepresentable = UIViewRepresentable | |
#endif | |
public extension Notification.Name { |
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 SwiftUI | |
import WebKit | |
#if os(macOS) | |
public typealias ViewRepresentable = NSViewRepresentable | |
#elseif os(iOS) | |
public typealias ViewRepresentable = UIViewRepresentable | |
#endif | |
public extension Notification.Name { |
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 XCTest | |
import ComposableArchitecture | |
@MainActor | |
final class AsyncRequestTests: XCTestCase { | |
let debounceDuration : DispatchQueue.SchedulerTimeType.Stride = 1 | |
let testQueue = DispatchQueue.test | |
let testString = ["A","B","C","D"] | |
func testPassThrough()async throws{ |
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 | |
struct AsyncRequestReducer<RequestType:Equatable, ResponseType:Equatable>: Reducer{ | |
@Dependency(\.mainQueue) var mainQueue | |
@Dependency(\.asyncRequestClient) var asyncRequestClient | |
struct State:Equatable{ | |
var debounceDuration : DispatchQueue.SchedulerTimeType.Stride | |
var response : ResponseType? = nil | |
} |
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 | |
extension AsyncRequestClient:DependencyKey{ | |
public static let liveValue: AsyncRequestClient = Self(fetch: {_ in | |
XCTFail("Unimplemented") | |
}) | |
public static let testValue: AsyncRequestClient = passThroughClient | |
} | |
extension DependencyValues{ | |
var asyncRequestClient: AsyncRequestClient{ |
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 AsyncRequestClient{ | |
var fetch: (any Sendable) async throws -> any Sendable | |
public static var passThroughClient = Self(fetch: {sendable in | |
return sendable | |
}) | |
public static var fetchArrayClient = Self(fetch: {sendable in | |
return [sendable] | |
}) | |
} |
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 XCTest | |
import ComposableArchitecture | |
@MainActor | |
final class BasicAsyncTaskTests: XCTestCase { | |
let debounceDuration : DispatchQueue.SchedulerTimeType.Stride = 1 | |
let testQueue = DispatchQueue.test | |
let testString = ["A","B","C","D"] | |
func test()async throws{ |
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 | |
struct BasicAsyncTaskReducer: Reducer{ | |
@Dependency(\.mainQueue) var mainQueue | |
struct State:Equatable{ | |
var debounceDuration : DispatchQueue.SchedulerTimeType.Stride | |
var response : String? = nil | |
} | |
enum Action:Equatable{ |
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 XCTest | |
import ComposableArchitecture | |
@MainActor | |
final class DebounceQueuedRequestTests: XCTestCase { | |
typealias State = QueuedRequestReducer.State | |
func test()async throws{ | |
let debounceDuration : DispatchQueue.SchedulerTimeType.Stride = 1 | |
let testQueue = DispatchQueue.test | |
let store = TestStore(initialState: State(debounceDuration:debounceDuration)) { |