### Method: connect() Source: https://pointfreeco.github.io/combine-schedulers/Publishers_Timer Connects the publisher to its upstream source, starting the timer. ```APIDOC ## connect() ### Description Connects the timer publisher to its upstream source, causing it to begin emitting events. ### Response #### Success Response (200) - **Cancellable** (Object) - A cancellable instance that can be used to stop the timer. ``` -------------------------------- ### ImmediateScheduler Usage Example Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Demonstrates how to use ImmediateScheduler for testing asynchronous operations. ```APIDOC ## Usage Example This example shows how to inject an `ImmediateScheduler` into a ViewModel to facilitate testing. **ViewModel without injectable scheduler:** ```swift class HomeViewModel: ObservableObject { @Published var episodes: [Episode]? let apiClient: ApiClient init(apiClient: ApiClient) { self.apiClient = apiClient } func reloadButtonTapped() { Just(()) .delay(for: .seconds(10), scheduler: DispatchQueue.main) .flatMap { apiClient.fetchEpisodes() } .assign(to: &self.episodes) } } ``` **Testing the above ViewModel requires waiting:** ```swift func testViewModel() { let viewModel = HomeViewModel(apiClient: .mock) viewModel.reloadButtonTapped() _ = XCTWaiter.wait(for: [XCTestExpectation()], timeout: 10) XCTAssert(viewModel.episodes, [Episode(id: 42)]) } ``` **ViewModel with injectable scheduler:** ```swift class HomeViewModel: ObservableObject { @Published var episodes: [Episode]? let apiClient: ApiClient let scheduler: AnySchedulerOf init(apiClient: ApiClient, scheduler: AnySchedulerOf) { self.apiClient = apiClient self.scheduler = scheduler } func reloadButtonTapped() { Just(()) .delay(for: .seconds(10), scheduler: self.scheduler) .flatMap { self.apiClient.fetchEpisodes() } .assign(to: &self.$episodes) } } ``` **Testing with ImmediateScheduler:** ```swift func testViewModel() { let viewModel = HomeViewModel( apiClient: .mock, scheduler: .immediate ) viewModel.reloadButtonTapped() // No more waiting... XCTAssert(viewModel.episodes, [Episode(id: 42)]) } ``` > **Note:** `ImmediateScheduler` is not suitable for testing complex timing logic like `Debounce`, `Throttle`, or `Timer.Publisher`. Use `TestScheduler` for such cases. ``` -------------------------------- ### Infinite Timer Example Source: https://pointfreeco.github.io/combine-schedulers/run%28%29 This example demonstrates an infinite loop scenario where scheduler.run() will never complete because the timer is set to run indefinitely. ```swift let scheduler = DispatchQueue.test Publishers.Timer(every: .seconds(1), scheduler: scheduler) .autoconnect() .sink { _ in print($0) } .store(in: &cancellables) scheduler.run() // Will never complete ``` -------------------------------- ### ImmediateScheduler Initializer Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Initializes an ImmediateScheduler with a specific starting time. ```APIDOC ## Initializers ### init(now:​) ```swift public init(now: SchedulerTimeType) ``` Creates an immediate test scheduler with the given date. #### Parameters Name | Type | Description ---|---|--- now | `Scheduler​Time​Type` | The current date of the test scheduler. ``` -------------------------------- ### EpisodeViewModel Example Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler An example of an EpisodeViewModel that uses an ApiClient and a main queue scheduler. The reloadButtonTapped function demonstrates receiving data on the main queue, while favoriteButtonTapped involves no scheduling. ```swift class EpisodeViewModel: ObservableObject { @Published var episode: Episode? let apiClient: ApiClient let mainQueue: AnySchedulerOf init(apiClient: ApiClient, mainQueue: AnySchedulerOf) { self.apiClient = apiClient self.mainQueue = mainQueue } func reloadButtonTapped() { self.apiClient.fetchEpisode() .receive(on: self.mainQueue) .assign(to: &self.$episode) } func favoriteButtonTapped() { self.episode?.isFavorite.toggle() } } ``` -------------------------------- ### Timer with Prefix Operator Source: https://pointfreeco.github.io/combine-schedulers/run%28%29 This example shows how to ensure a publisher completes by using the 'prefix' operator to limit the timer's execution. The scheduler.run() will complete after printing 3 times. ```swift let scheduler = DispatchQueue.test Publishers.Timer(every: .seconds(1), scheduler: scheduler) .autoconnect() .prefix(3) .sink { _ in print($0) } .store(in: &cancellables) scheduler.run() // Prints 3 times and completes. ``` -------------------------------- ### Test Publishers.Timer with TestScheduler Source: https://pointfreeco.github.io/combine-schedulers/Publishers_Timer This example demonstrates how to use Publishers.Timer with a TestScheduler for highly testable timer-based Combine code. It shows advancing time and asserting output. ```swift let scheduler = DispatchQueue.test var output: [Int] = [] Publishers.Timer(every: 1, scheduler: scheduler) .autoconnect() .sink { _ in output.append(output.count) } .store(in: &self.cancellables) XCTAssertEqual(output, []) scheduler.advance(by: 1) XCTAssertEqual(output, [0]) scheduler.advance(by: 1) XCTAssertEqual(output, [0, 1]) scheduler.advance(by: 1_000) XCTAssertEqual(output, Array(0...1_001)) ``` -------------------------------- ### ViewModel with DispatchQueue.main Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler An example of an ObservableObject ViewModel that uses DispatchQueue.main for receiving network responses. This approach makes testing more difficult due to the need for explicit waits. ```swift class EpisodeViewModel: ObservableObject { @Published var episode: Episode? let apiClient: ApiClient init(apiClient: ApiClient) { self.apiClient = apiClient } func reloadButtonTapped() { self.apiClient.fetchEpisode() .receive(on: DispatchQueue.main) .assign(to: &self.$episode) } } ``` -------------------------------- ### Instantiate Publishers.Timer with DispatchQueue Source: https://pointfreeco.github.io/combine-schedulers/Publishers_Timer Use Publishers.Timer to create a repeating timer on a specific scheduler, such as DispatchQueue.main. This publisher can be autoconnected to start emissions immediately. ```swift Publishers.Timer(every: .seconds(1), scheduler: DispatchQueue.main) .autoconnect() .sink { print("Timer", $0) } ``` -------------------------------- ### ImmediateScheduler Initializer Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Initializes an ImmediateScheduler with a specific current date. This is used to set the starting point for the scheduler's time. ```swift public init(now: SchedulerTimeType) ``` -------------------------------- ### Schedule Action with Interval and Tolerance Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Schedule an action to be performed repeatedly at a specified interval, starting after a given date. The tolerance parameter allows for flexibility in execution timing. ```swift public func schedule( after date: SchedulerTimeType, interval: SchedulerTimeType.Stride, tolerance: SchedulerTimeType.Stride, options: SchedulerOptions?, _ action: @escaping () -> Void ) -> Cancellable ``` -------------------------------- ### Usage of sleep function Source: https://pointfreeco.github.io/combine-schedulers/sleep%28for_tolerance_options_%29 Example of calling the sleep function within an asynchronous context. ```swift try await in scheduler.sleep(for: .seconds(1)) ``` -------------------------------- ### Get Current Scheduler Time Source: https://pointfreeco.github.io/combine-schedulers/now Access the current time of the scheduler. This property is publicly readable but privately settable. ```swift public private(set) var now: SchedulerTimeType ``` -------------------------------- ### UIScheduler Schedule After Interval Method Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Schedules a recurring action to be performed at a specified interval, starting after a given date, with a defined tolerance. Returns a Cancellable to manage the scheduled operation. ```swift public func schedule(after date: SchedulerTimeType, interval: SchedulerTimeType.Stride, tolerance: SchedulerTimeType.Stride, options: SchedulerOptions? = nil, _ action: @escaping () -> Void) -> Cancellable ``` -------------------------------- ### Use sleep function in CombineSchedulers Source: https://pointfreeco.github.io/combine-schedulers/sleep%28until_tolerance_options_%29 Example of how to use the `sleep` function to suspend task execution for a specified duration. Ensure the scheduler is available and the operation is within a `try await` context. ```swift try await in scheduler.sleep(until: scheduler.now + .seconds(1)) ``` -------------------------------- ### Initializer: init(every:tolerance:scheduler:options:) Source: https://pointfreeco.github.io/combine-schedulers/Publishers_Timer Initializes a new timer publisher that emits the scheduler's current time on a repeating interval. ```APIDOC ## init(every:tolerance:scheduler:options:) ### Description Creates a publisher that emits the scheduler's current time on a repeating interval. This is designed to be used with any Combine Scheduler, including TestScheduler for deterministic testing. ### Parameters #### Request Body - **every** (Scheduler.SchedulerTimeType.Stride) - Required - The interval at which to emit events. - **tolerance** (Scheduler.SchedulerTimeType.Stride?) - Optional - The allowed tolerance for the timer. - **scheduler** (Scheduler) - Required - The scheduler on which to perform the timer operations. - **options** (Scheduler.SchedulerOptions?) - Optional - Options for the scheduler. ``` -------------------------------- ### Create ViewModel with .immediate Scheduler Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Instantiates an EpisodeViewModel using the static .immediate scheduler for testing purposes. This scheduler executes tasks immediately. ```swift let viewModel = EpisodeViewModel( apiClient: ..., scheduler: .immediate ) ``` -------------------------------- ### schedule(options:_:) Source: https://pointfreeco.github.io/combine-schedulers/schedule%28options___%29 Documentation for the schedule function used to execute actions on a scheduler. ```APIDOC ## schedule(options:_:) ### Description Schedules an action to be performed on the scheduler, optionally using specific scheduler options. ### Method Function Call ### Parameters #### Parameters - **options** (SchedulerOptions?) - Optional - Configuration options for the scheduler. - **action** (() -> Void) - Required - The closure to be executed. ``` -------------------------------- ### Create ViewModel with .main Scheduler Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler A simplified way to create an EpisodeViewModel using the static .main scheduler, which is a type-erased DispatchQueue.main. ```swift let viewModel = EpisodeViewModel( apiClient: ..., scheduler: .main ) ``` -------------------------------- ### Scheduler Initialization Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Initializers for creating type-erasing schedulers. ```APIDOC ## `init(minimumTolerance:now:scheduleImmediately:delayed:interval:)` ### Description Creates a type-erasing scheduler to wrap the provided endpoints. ### Parameters #### Path Parameters - **minimumTolerance** (`@escaping () -> SchedulerTimeType.Stride`) - Required - A closure that returns the scheduler's minimum tolerance. - **now** (`@escaping () -> SchedulerTimeType`) - Required - A closure that returns the scheduler's current time. - **scheduleImmediately** (`@escaping (SchedulerOptions?, @escaping () -> Void) -> Void`) - Required - A closure that schedules a unit of work to be run as soon as possible. - **delayed** (`@escaping (SchedulerTimeType, SchedulerTimeType.Stride, SchedulerOptions?, @escaping () -> Void) -> Void`) - Required - A closure that schedules a unit of work to be run after a delay. - **interval** (`@escaping (SchedulerTimeType, SchedulerTimeType.Stride, SchedulerTimeType.Stride, SchedulerOptions?, @escaping () -> Void) -> Cancellable`) - Required - A closure that schedules a unit of work to be performed on a repeating interval. ## `init(_:)` ### Description Creates a type-erasing scheduler to wrap the provided scheduler. ### Parameters #### Path Parameters - **scheduler** (`S`) - Required - A scheduler to wrap with a type-eraser. ``` -------------------------------- ### Testing ViewModel with ImmediateScheduler Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler This test demonstrates how to use ImmediateScheduler with the HomeViewModel. By providing .immediate as the scheduler, the delayed operation executes instantly, eliminating the need for waiting. ```swift func testViewModel() { let viewModel = HomeViewModel( apiClient: .mock, scheduler: .immediate ) viewModel.reloadButtonTapped() // No more waiting... XCTAssert(viewModel.episodes, [Episode(id: 42)]) } ``` -------------------------------- ### Schedule Action at Next Opportunity Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler This method schedules an action to be executed at the earliest possible opportunity according to the scheduler's policies. It's suitable for tasks that need to run as soon as feasible. ```swift public func schedule( options: SchedulerOptions?, _ action: @escaping () -> Void ) ``` -------------------------------- ### ImmediateScheduler Structure Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Details the structure and conformance of the ImmediateScheduler. ```APIDOC ## ImmediateScheduler Structure ```swift public struct ImmediateScheduler: Scheduler where SchedulerTimeType: Strideable, SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible ``` A scheduler for performing synchronous actions. This scheduler ignores specified dates and performs actions immediately. It is particularly useful for testing asynchronous operations in publishers without actual delays, unlike `TestScheduler` which allows explicit time control. It collapses time into a single point. ``` -------------------------------- ### ImmediateScheduler Methods Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Methods available on the ImmediateScheduler for scheduling actions. ```APIDOC ## Methods ### schedule(options:​_:​) ```swift public func schedule(options _: SchedulerOptions?, _ action: () -> Void) ``` ### schedule(after:​tolerance:​options:​_:​) ```swift public func schedule( after _: SchedulerTimeType, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: () -> Void ) ``` ### schedule(after:​interval:​tolerance:​options:​_:​) ```swift public func schedule( after _: SchedulerTimeType, interval _: SchedulerTimeType.Stride, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: () -> Void ) -> Cancellable ``` ``` -------------------------------- ### Run Scheduler Until Empty Source: https://pointfreeco.github.io/combine-schedulers/run%28%29 Use this method to ensure a publisher completes. It runs the scheduler until no scheduled items remain. Be aware that infinite loops will not complete. ```swift public func run() ``` -------------------------------- ### schedule(after:tolerance:options:_:) Source: https://pointfreeco.github.io/combine-schedulers/schedule%28after_tolerance_options___%29 Schedules an action to be performed after a specified date with a given tolerance and options. ```APIDOC ## schedule(after:tolerance:options:_:) ### Description Schedules an action to be performed after a specified date with a given tolerance and options. ### Parameters #### Parameters - **after** (SchedulerTimeType) - Required - The date after which the action should be performed. - **tolerance** (SchedulerTimeType.Stride) - Required - The tolerance allowed for the scheduled action. - **options** (SchedulerOptions?) - Optional - Options for the scheduler. - **action** (() -> Void) - Required - The closure to be executed. ``` -------------------------------- ### Create ViewModel with Erased DispatchQueue.main Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Instantiates an EpisodeViewModel using a type-erased DispatchQueue.main scheduler for production environments. ```swift let viewModel = EpisodeViewModel( apiClient: ..., scheduler: DispatchQueue.main.eraseToAnyScheduler() ) ``` -------------------------------- ### advance(to:) Source: https://pointfreeco.github.io/combine-schedulers/advance%28to_%29 Advances the scheduler to a specified instant in time. ```APIDOC ## advance(to:) ### Description Advances the scheduler to the given instant. ### Parameters #### Path Parameters - **instant** (SchedulerTimeType) - Required - An instant in time to advance to. ``` -------------------------------- ### Scheduler Methods Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Methods for scheduling actions on a scheduler. ```APIDOC ## Methods ### `schedule(after:tolerance:options:_:)` #### Description Performs the action at some time after the specified date. ### `schedule(after:interval:tolerance:options:_:)` #### Description Performs the action at some time after the specified date, at the specified frequency, taking into account tolerance if possible. ### `schedule(options:_:)` #### Description Performs the action at the next possible opportunity. ``` -------------------------------- ### Use Timer to Print Current Time Source: https://pointfreeco.github.io/combine-schedulers/timer%28interval_tolerance_options_%29 Demonstrates how to use the timer function to repeatedly print the current scheduler time every second. The loop terminates if the task is cancelled. ```swift for await instant in scheduler.timer(interval: .seconds(1)) { print("now:", instant) } ``` -------------------------------- ### UIScheduler API Reference Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Documentation for the UIScheduler struct, its properties, and scheduling methods. ```APIDOC ## UIScheduler ### Description A scheduler that executes its work on the main queue as soon as possible. If invoked from the main thread, work is performed immediately, avoiding the thread hop associated with DispatchQueue.main.async. ### Properties - **shared** (static) - The shared instance of the UI scheduler. - **test** (static) - A test scheduler compatible with type erased UI schedulers. - **now** (SchedulerTimeType) - The current time of the scheduler. - **minimumTolerance** (SchedulerTimeType.Stride) - The minimum tolerance for scheduling. ### Methods - **schedule(options: _:)** - Schedules a unit of work to be performed immediately. - **schedule(after:tolerance:options:_:)** - Schedules a unit of work to be performed after a specific date. - **schedule(after:interval:tolerance:options:_:)** - Schedules a repeating unit of work to be performed after a specific date. ``` -------------------------------- ### ImmediateScheduler Properties Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Properties of the ImmediateScheduler. ```APIDOC ## Properties ### minimum​Tolerance ```swift public let minimumTolerance: SchedulerTimeType.Stride = .zero ``` ### now ```swift public let now: SchedulerTimeType ``` ``` -------------------------------- ### Advance Scheduler to Instant Source: https://pointfreeco.github.io/combine-schedulers/advance%28to_%29 Advances the scheduler to the given instant. Use this function to move the scheduler's time forward. ```swift public func advance(to instant: SchedulerTimeType) ``` ```swift @MainActor public func advance(to instant: SchedulerTimeType) ``` -------------------------------- ### CombineSchedulers - run() Source: https://pointfreeco.github.io/combine-schedulers/run%28%29 The run() function executes the scheduler until all scheduled items are processed. It's useful for testing publisher completion and preventing infinite loops. ```APIDOC ## func run() ### Description Runs the scheduler until it has no scheduled items left. This method is useful for proving exhaustively that your publisher eventually completes and does not run forever. ### Method `public func run()` ### Endpoint N/A (This is a function within a library, not a REST endpoint) ### Parameters None ### Request Body None ### Response None ### Example Usage ```swift let scheduler = DispatchQueue.test Publishers.Timer(every: .seconds(1), scheduler: scheduler) .autoconnect() .prefix(3) .sink { _ in print($0) } // Prints 3 times and completes. .store(in: &cancellables) scheduler.run() ``` ### Notes - The `@MainActor` annotation indicates that this function should be called on the main thread. - Use `prefix` or other operators to ensure publishers complete when using `run()` to avoid infinite execution. ``` -------------------------------- ### Schedule Action After a Specific Date Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Use this method to perform a given action at some point after a specified date. It does not guarantee execution at the exact date but rather sometime after it. ```swift public func schedule( after date: SchedulerTimeType, tolerance: SchedulerTimeType.Stride, options: SchedulerOptions?, _ action: @escaping () -> Void ) ``` -------------------------------- ### ViewModel with ImmediateScheduler for Testing Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler This ViewModel injects a scheduler, allowing for testing with ImmediateScheduler. It uses Combine's delay operator with the provided scheduler. ```swift class HomeViewModel: ObservableObject { @Published var episodes: [Episode]? let apiClient: ApiClient let scheduler: AnySchedulerOf init(apiClient: ApiClient, scheduler: AnySchedulerOf) { self.apiClient = apiClient self.scheduler = scheduler } func reloadButtonTapped() { Just(()) .delay(for: .seconds(10), scheduler: self.scheduler) .flatMap { self.apiClient.fetchEpisodes() } .assign(to: &self.$episodes) } } ``` -------------------------------- ### Initialize Type-Erasing Scheduler with Endpoints Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Use this initializer to create a type-erasing scheduler by providing closures for its core functionalities: minimum tolerance, current time, immediate scheduling, delayed scheduling, and interval scheduling. ```swift public init( minimumTolerance: @escaping () -> SchedulerTimeType.Stride, now: @escaping () -> SchedulerTimeType, scheduleImmediately: @escaping (SchedulerOptions?, @escaping () -> Void) -> Void, delayed: @escaping ( SchedulerTimeType, SchedulerTimeType.Stride, SchedulerOptions?, @escaping () -> Void ) -> Void, interval: @escaping ( SchedulerTimeType, SchedulerTimeType.Stride, SchedulerTimeType.Stride, SchedulerOptions?, @escaping () -> Void ) -> Cancellable ) ``` -------------------------------- ### ViewModel with Generic Scheduler Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler A generic ViewModel that accepts any Scheduler type. This improves testability by allowing different schedulers to be injected, but introduces generics that can propagate. ```swift class EpisodeViewModel: ObservableObject { @Published var episode: Episode? let apiClient: ApiClient let scheduler: S init(apiClient: ApiClient, scheduler: S) { self.apiClient = apiClient self.scheduler = scheduler } func reloadButtonTapped() { self.apiClient.fetchEpisode() .receive(on: self.scheduler) .assign(to: &self.$episode) } } ``` -------------------------------- ### Scheduler Properties Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Properties available on scheduler instances. ```APIDOC ## Properties ### `minimumTolerance` #### Description The minimum tolerance allowed by the scheduler. ### `now` #### Description This scheduler’s definition of the current moment in time. ``` -------------------------------- ### Testing ViewModel with Delay (Requires Waiting) Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler This test function shows how to test the HomeViewModel when it uses DispatchQueue.main for delays. It requires explicitly waiting for the delayed operation to complete. ```swift func testViewModel() { let viewModel = HomeViewModel(apiClient: .mock) viewModel.reloadButtonTapped() _ = XCTWaiter.wait(for: [XCTestExpectation()], timeout: 10) XCTAssert(viewModel.episodes, [Episode(id: 42)]) } ``` -------------------------------- ### Initialize UnimplementedScheduler Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Initializes an unimplemented scheduler with a prefix string and the current time. The prefix is used to identify the scheduler in failure messages. ```swift public init(_ prefix: String = "", now: SchedulerTimeType) ``` -------------------------------- ### schedule(after:interval:tolerance:options:_:) Source: https://pointfreeco.github.io/combine-schedulers/schedule%28after_interval_tolerance_options___%29 Schedules a recurring action to be performed on the scheduler at a specified interval. ```APIDOC ## schedule(after:interval:tolerance:options:_:) ### Description Schedules a recurring action to be performed on the scheduler starting after a specific date, repeating at a defined interval. ### Parameters - **after** (SchedulerTimeType) - Required - The date after which the action should start. - **interval** (SchedulerTimeType.Stride) - Required - The interval at which the action should repeat. - **tolerance** (SchedulerTimeType.Stride) - Required - The allowed tolerance for the timing of the action. - **options** (SchedulerOptions?) - Optional - Options for the scheduler. - **action** (@escaping () -> Void) - Required - The closure to execute. ### Response - **Cancellable** - Returns a cancellable object that can be used to stop the scheduled action. ``` -------------------------------- ### ImmediateScheduler now Property Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Represents the current time of the scheduler. For ImmediateScheduler, this is a fixed value set during initialization. ```swift public let now: SchedulerTimeType ``` -------------------------------- ### ImmediateScheduler Structure Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler Defines the ImmediateScheduler, a struct conforming to the Scheduler protocol. It's designed for performing synchronous actions immediately. ```swift public struct ImmediateScheduler: Scheduler where SchedulerTimeType: Strideable, SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible ``` -------------------------------- ### Scheduler Types Source: https://pointfreeco.github.io/combine-schedulers Provides various scheduler implementations for different use cases. ```APIDOC ## Scheduler Structures ### AnyScheduler A type-erasing wrapper for the `Scheduler` protocol, which can be useful for being generic over many types of schedulers without needing to actually introduce a generic to your code. ### ImmediateScheduler A scheduler for performing synchronous actions. ### UIScheduler A scheduler that executes its work on the main queue as soon as possible. ### UnimplementedScheduler A scheduler that causes the current XCTest test case to fail if it is used. ``` -------------------------------- ### UnimplementedScheduler prefix Property Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler A string that identifies this scheduler and will prefix all failure messages. This is useful for debugging when the unimplemented scheduler is accidentally invoked. ```swift public let prefix: String ``` -------------------------------- ### Scheduler Variables Source: https://pointfreeco.github.io/combine-schedulers Variables related to scheduler configurations. ```APIDOC ## Scheduler Variables ### minimumTolerance The minimum tolerance for scheduler operations. ### now The current time of the scheduler. ``` -------------------------------- ### UIScheduler Schedule After Date Method Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Schedules a single action to be performed after a specified date, with a given tolerance. The action executes on the main queue. ```swift public func schedule(after date: SchedulerTimeType, tolerance: SchedulerTimeType.Stride, options: SchedulerOptions? = nil, _ action: @escaping () -> Void) ``` -------------------------------- ### Initialize Type-Erasing Scheduler with Another Scheduler Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler This initializer creates a type-erasing scheduler that wraps an existing scheduler conforming to the `Scheduler` protocol. Ensure the wrapped scheduler's time type and options match. ```swift public init( _ scheduler: S ) where S: Scheduler, S.SchedulerTimeType == SchedulerTimeType, S.SchedulerOptions == SchedulerOptions ``` -------------------------------- ### Schedule function signature Source: https://pointfreeco.github.io/combine-schedulers/schedule%28options___%29 Defines the interface for scheduling an action on a scheduler with optional configuration. ```swift public func schedule(options _: SchedulerOptions?, _ action: @escaping () -> Void) ``` -------------------------------- ### Scheduler Functions Source: https://pointfreeco.github.io/combine-schedulers Functions for controlling and interacting with schedulers. ```APIDOC ## Scheduler Functions ### sleep(for:tolerance:options:) Suspends the current task for at least the given duration. ### sleep(until:tolerance:options:) Suspend task execution until a given deadline within a tolerance. ### timer(interval:tolerance:options:) Returns a stream that repeatedly yields the current time of the scheduler on a given interval. ### measure(_:) Measure the elapsed time to execute a closure. ### advance(by:) Advances the scheduler by the given stride. ### advance(to:) Advances the scheduler to the given instant. ### run() Runs the scheduler until it has no scheduled items left. ### schedule(after:interval:tolerance:options:_:) ### schedule(after:tolerance:options:_:) ### schedule(options:_:) Schedules work to be performed on the scheduler. ``` -------------------------------- ### Schedule action in CombineSchedulers Source: https://pointfreeco.github.io/combine-schedulers/schedule%28after_tolerance_options___%29 Defines the signature for scheduling an action after a specific date with tolerance and options. ```swift public func schedule( after date: SchedulerTimeType, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: @escaping () -> Void ) ``` -------------------------------- ### UnimplementedScheduler schedule Method (after, interval, tolerance) Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Schedules a closure to be executed repeatedly at a given interval, after an initial delay, with a specified tolerance. This method returns a Cancellable object. For UnimplementedScheduler, its invocation leads to a test failure. ```swift public func schedule( after _: SchedulerTimeType, interval _: SchedulerTimeType.Stride, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: () -> Void ) -> Cancellable ``` -------------------------------- ### Declare minimumTolerance SchedulerTimeType.Stride Source: https://pointfreeco.github.io/combine-schedulers/minimumTolerance Defines the minimum tolerance for scheduler time operations, initialized to zero. ```swift public let minimumTolerance: SchedulerTimeType.Stride = .zero ``` -------------------------------- ### Run Scheduler Until Empty (MainActor) Source: https://pointfreeco.github.io/combine-schedulers/run%28%29 This is the MainActor-isolated version of the run() function, used for executing scheduled items on the main thread until the scheduler is empty. ```swift @MainActor public func run() ``` -------------------------------- ### UIScheduler Shared Instance Property Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Provides the shared, singleton instance of the UIScheduler. Instances of UIScheduler cannot be created directly; only the shared instance should be used. ```swift public static let shared ``` -------------------------------- ### Advance Scheduler Time Source: https://pointfreeco.github.io/combine-schedulers/advance%28by_%29 Advances the scheduler by the given stride. When the duration is `.zero`, it executes pending work without advancing time. ```swift public func advance(by duration: SchedulerTimeType.Stride = .zero) ``` ```swift @MainActor public func advance(by duration: SchedulerTimeType.Stride = .zero) ``` -------------------------------- ### UIScheduler Schedule Action Method Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Schedules a single action to be performed on the main queue. If invoked from the main thread, the action is executed immediately. ```swift public func schedule(options: SchedulerOptions? = nil, _ action: @escaping () -> Void) ``` -------------------------------- ### Property: minimumTolerance Source: https://pointfreeco.github.io/combine-schedulers/minimumTolerance Documentation for the minimumTolerance property used in CombineSchedulers. ```APIDOC ## Property: minimumTolerance ### Description The minimum tolerance allowed for the scheduler time type. ### Definition `public let minimumTolerance: SchedulerTimeType.Stride = .zero` ``` -------------------------------- ### Function advance(by:) Source: https://pointfreeco.github.io/combine-schedulers/advance%28by_%29 Advances the scheduler by a specified duration. This function is crucial for testing and manipulating time within Combine-based applications. ```APIDOC ## Function advance(by:) ### Description Advances the scheduler by the given stride. This function is essential for controlling and testing time-dependent operations in Combine. ### Method `public func` ### Endpoint N/A (This is a function, not an API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift // Example usage: // scheduler.advance(by: .seconds(5)) ``` ### Response #### Success Response (200) N/A (This is a function call, not an API request/response) #### Response Example N/A ``` -------------------------------- ### timer(interval:tolerance:options:) Source: https://pointfreeco.github.io/combine-schedulers/timer%28interval_tolerance_options_%29 Returns a stream that repeatedly yields the current time of the scheduler on a given interval. If the task is cancelled, the sequence will terminate. ```APIDOC ## timer(interval:tolerance:options:) ### Description Returns a stream that repeatedly yields the current time of the scheduler on a given interval. If the task is cancelled, the sequence will terminate. ### Parameters - **interval** (SchedulerTimeType.Stride) - Required - The time interval on which to sleep between yielding the current instant in time. - **tolerance** (SchedulerTimeType.Stride) - Optional - The allowed timing variance when emitting events. Defaults to zero. - **options** (SchedulerOptions?) - Optional - Scheduler options passed to the timer. Defaults to nil. ### Returns A stream that repeatedly yields the current time. ### Request Example for await instant in scheduler.timer(interval: .seconds(1)) { print("now:", instant) } ``` -------------------------------- ### UnimplementedScheduler schedule Method (after and tolerance) Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Schedules a closure to be executed after a specified time with a given tolerance. Invoking this method on an UnimplementedScheduler will result in a test failure. ```swift public func schedule( after _: SchedulerTimeType, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: () -> Void ) ``` -------------------------------- ### UIScheduler Test Scheduler Property Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Provides a static test scheduler compatible with type-erased UI schedulers. This is useful for testing scenarios involving the UIScheduler. ```swift public static var test: TestSchedulerOf ``` -------------------------------- ### Publishers.Timer Source: https://pointfreeco.github.io/combine-schedulers A publisher that emits the scheduler's current time on a repeating interval. ```APIDOC ## Publishers.Timer ### Description A publisher that emits a scheduler's current time on a repeating interval. ### Type Class ``` -------------------------------- ### UnimplementedScheduler now Property Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Provides the current time for the scheduler. In the context of UnimplementedScheduler, this value is set during initialization and is not dynamically updated. ```swift public var now: SchedulerTimeType ``` -------------------------------- ### ImmediateSchedulerOf Typealias Source: https://pointfreeco.github.io/combine-schedulers/ImmediateSchedulerOf Defines a convenience typealias for ImmediateScheduler, allowing it to be specified by the scheduler it wraps. ```APIDOC ## Typealias ImmediateSchedulerOf ### Description A convenience type to specify an `ImmediateScheduler` by the scheduler it wraps rather than by the time type and options type. ### Syntax ```swift public typealias ImmediateSchedulerOf = ImmediateScheduler< Scheduler.SchedulerTimeType, Scheduler.SchedulerOptions > where Scheduler: Combine.Scheduler ``` ### Parameters #### Type Parameters - **Scheduler** (Combine.Scheduler) - The scheduler type that `ImmediateSchedulerOf` will wrap. ``` -------------------------------- ### ViewModel with AnySchedulerOf Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler A ViewModel using AnySchedulerOf to accept a type-erased DispatchQueue scheduler. This avoids introducing generics while still allowing scheduler substitution. ```swift class EpisodeViewModel: ObservableObject { @Published var episode: Episode? let apiClient: ApiClient let scheduler: AnySchedulerOf init(apiClient: ApiClient, scheduler: AnySchedulerOf) { self.apiClient = apiClient self.scheduler = scheduler } func reloadButtonTapped() { self.apiClient.fetchEpisode() .receive(on: self.scheduler) .assign(to: &self.$episode) } } ``` -------------------------------- ### Scheduler Typealiases Source: https://pointfreeco.github.io/combine-schedulers Convenience typealiases for specifying schedulers. ```APIDOC ## Scheduler Typealiases ### AnySchedulerOf A convenience type to specify an `AnyScheduler` by the scheduler it wraps rather than by the time type and options type. ### ImmediateSchedulerOf A convenience type to specify an `ImmediateScheduler` by the scheduler it wraps rather than by the time type and options type. ### FailingScheduler ### FailingSchedulerOf ### TestSchedulerOf A convenience type to specify a `TestScheduler` by the scheduler it wraps rather than by the time type and options type. ### UnimplementedSchedulerOf A convenience type to specify an `UnimplementedScheduler` by the scheduler it wraps rather than by the time type and options type. ``` -------------------------------- ### Function measure(_:) Source: https://pointfreeco.github.io/combine-schedulers/measure%28__%29 Measures the elapsed time to execute a given closure on a scheduler. ```APIDOC ## `measure(_:)` ### Description Measures the elapsed time to execute a closure. ### Method `public func measure(_ work: () throws -> Void) rethrows -> SchedulerTimeType.Stride` ### Parameters #### Path Parameters - **work** (`() throws -> Void`) - Required - A closure to execute. ### Request Example ```swift let elapsed = scheduler.measure { someWork() } ``` ### Response #### Success Response (200) - **Stride** (`SchedulerTimeType.Stride`) - The amount of time it took to execute the closure. #### Response Example ```swift // Example of elapsed time (actual value depends on execution time) let elapsed: Double = 0.001 ``` ``` -------------------------------- ### Declare Timer Function Signature Source: https://pointfreeco.github.io/combine-schedulers/timer%28interval_tolerance_options_%29 Defines the signature for the timer function, specifying its parameters for interval, tolerance, and options, and its return type as an AsyncStream of SchedulerTimeType. ```swift public func timer( interval: SchedulerTimeType.Stride, tolerance: SchedulerTimeType.Stride = .zero, options: SchedulerOptions? = nil ) -> AsyncStream ``` -------------------------------- ### UnimplementedScheduler schedule Method (no options) Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Schedules a closure to be executed. For UnimplementedScheduler, calling this method will cause the current test case to fail. ```swift public func schedule(options _: SchedulerOptions?, _ action: () -> Void) ``` -------------------------------- ### Function sleep(until:tolerance:options:) Source: https://pointfreeco.github.io/combine-schedulers/sleep%28until_tolerance_options_%29 Suspend task execution until a given deadline within a tolerance. This function does not block the scheduler. ```APIDOC ## Function sleep(until:tolerance:options:) ### Description Suspend task execution until a given deadline within a tolerance. If the task is cancelled before the time ends, this function throws `CancellationError`. This function doesn't block the scheduler. ### Method `async` (implicitly) ### Endpoint N/A (This is a function within a library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift try await in scheduler.sleep(until: scheduler.now + .seconds(1)) ``` ### Response #### Success Response (200) N/A (This is a function, not an API endpoint returning a status code) #### Response Example N/A ### Error Handling - `CancellationError`: Thrown if the task is cancelled before the sleep duration ends. ``` -------------------------------- ### Define UnimplementedScheduler Structure Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Defines the UnimplementedScheduler struct, which conforms to the Scheduler protocol. This scheduler is intended to fail tests if used, ensuring that tested code does not require actual scheduling. ```swift public struct UnimplementedScheduler: where SchedulerTimeType: Strideable, SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible ``` -------------------------------- ### ViewModel with Delay Operator Source: https://pointfreeco.github.io/combine-schedulers/ImmediateScheduler This ViewModel uses Combine's delay operator with DispatchQueue.main. It's designed to load data after a 10-second delay when a button is tapped. ```swift class HomeViewModel: ObservableObject { @Published var episodes: [Episode]? let apiClient: ApiClient init(apiClient: ApiClient) { self.apiClient = apiClient } func reloadButtonTapped() { Just(()) .delay(for: .seconds(10), scheduler: DispatchQueue.main) .flatMap { apiClient.fetchEpisodes() } .assign(to: &self.episodes) } } ``` -------------------------------- ### Define UIScheduler Structure Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Defines the UIScheduler structure, conforming to Scheduler and Sendable. It executes work on the main queue immediately if invoked from the main thread. ```swift public struct UIScheduler: Scheduler, Sendable ``` -------------------------------- ### Schedule Function Signature Source: https://pointfreeco.github.io/combine-schedulers/schedule%28after_interval_tolerance_options___%29 This is the function signature for scheduling an action to occur after a specified date, with a given interval, tolerance, and options. It returns a Cancellable object. ```swift public func schedule( after date: SchedulerTimeType, interval: SchedulerTimeType.Stride, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: @escaping () -> Void ) -> Cancellable ``` -------------------------------- ### UIScheduler Now Property Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Represents the current time according to the UIScheduler's time base. ```swift public var now: SchedulerTimeType ``` -------------------------------- ### Define TestSchedulerOf Type Alias Source: https://pointfreeco.github.io/combine-schedulers/TestSchedulerOf Use this type alias to create a TestScheduler that wraps an existing Combine.Scheduler. It simplifies the declaration of TestScheduler by using the scheduler it's based on. ```swift public typealias TestSchedulerOf = TestScheduler< Scheduler.SchedulerTimeType, Scheduler.SchedulerOptions > where Scheduler: Combine.Scheduler ``` -------------------------------- ### Test Favorite Button with UnimplementedScheduler Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler A unit test for the favoriteButtonTapped function of EpisodeViewModel, using an unimplemented scheduler for the main queue. This test asserts that toggling favorite status does not require scheduling. ```swift func testFavoriteButton() { let viewModel = EpisodeViewModel( apiClient: .mock, mainQueue: .unimplemented ) viewModel.episode = .mock viewModel.favoriteButtonTapped() XCTAssert(viewModel.episode?.isFavorite == true) viewModel.favoriteButtonTapped() XCTAssert(viewModel.episode?.isFavorite == false) } ``` -------------------------------- ### CombineSchedulers - Now Variable Source: https://pointfreeco.github.io/combine-schedulers/now This section details the `now` variable within CombineSchedulers, which represents the current scheduler time. ```APIDOC ## CombineSchedulers - Now Variable ### Description Represents the current time according to the scheduler. ### Variable `now` ### Type `SchedulerTimeType` ### Access `public private(set)` ``` -------------------------------- ### Measure Elapsed Time of Work Source: https://pointfreeco.github.io/combine-schedulers/measure%28__%29 Use the `measure` function to determine the time taken to execute a closure on a scheduler. Ensure the scheduler is properly initialized before use. ```swift public func measure(_ work: () throws -> Void) rethrows -> SchedulerTimeType.Stride ``` ```swift let elapsed = scheduler.measure { someWork() } ``` -------------------------------- ### Define AnyScheduler Structure Source: https://pointfreeco.github.io/combine-schedulers/AnyScheduler Defines the AnyScheduler structure, a type-erasing wrapper for the Scheduler protocol. It's useful for making code generic over schedulers without explicit generics. ```swift public struct AnyScheduler: Scheduler, @unchecked Sendable where SchedulerTimeType: Strideable, SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible ``` -------------------------------- ### Function sleep(for:tolerance:options:) Source: https://pointfreeco.github.io/combine-schedulers/sleep%28for_tolerance_options_%29 Suspends the current task for at least the given duration without blocking the scheduler. Throws CancellationError if cancelled before completion. ```APIDOC ## Function sleep(for:tolerance:options:) ### Description Suspends the current task for at least the given duration. If the task is cancelled before the time ends, this function throws `CancellationError`. This function doesn't block the scheduler. ### Method `async` (implied by `try await` usage) ### Endpoint N/A (This is a function within a library, not a network endpoint) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```swift try await in scheduler.sleep(for: .seconds(1)) ``` ### Response #### Success Response (200) N/A (This is a function, not an API endpoint with a typical response) #### Response Example N/A ``` -------------------------------- ### AnySchedulerOf Typealias Source: https://pointfreeco.github.io/combine-schedulers/AnySchedulerOf The AnySchedulerOf typealias simplifies the declaration of AnyScheduler by allowing you to specify the wrapped scheduler directly. ```APIDOC ## Typealias AnySchedulerOf ### Description A convenience type to specify an `AnyScheduler` by the scheduler it wraps rather than by the time type and options type. ### Syntax ```swift public typealias AnySchedulerOf = AnyScheduler< Scheduler.SchedulerTimeType, Scheduler.SchedulerOptions > where Scheduler: Combine.Scheduler ``` ### Type Parameters - **Scheduler**: A type conforming to `Combine.Scheduler`. ``` -------------------------------- ### FailingScheduler Typealias Source: https://pointfreeco.github.io/combine-schedulers/FailingScheduler This section describes the `FailingScheduler` typealias, which is deprecated and renamed to `UnimplementedScheduler` across all platforms. ```APIDOC ## Typealias FailingScheduler ### Description The `FailingScheduler` typealias is deprecated and has been renamed to `UnimplementedScheduler`. ### Deprecation Details - **iOS**: Deprecated, renamed to `UnimplementedScheduler`. - **macOS**: Deprecated, renamed to `UnimplementedScheduler`. - **tvOS**: Deprecated, renamed to `UnimplementedScheduler`. - **watchOS**: Deprecated, renamed to `UnimplementedScheduler`. ### Code Example ```swift @available(iOS, deprecated: 9999.0, renamed: "UnimplementedScheduler") @available(macOS, deprecated: 9999.0, renamed: "UnimplementedScheduler") @available(tvOS, deprecated: 9999.0, renamed: "UnimplementedScheduler") @available(watchOS, deprecated: 9999.0, renamed: "UnimplementedScheduler") public typealias FailingScheduler = UnimplementedScheduler ``` ``` -------------------------------- ### UIScheduler Minimum Tolerance Property Source: https://pointfreeco.github.io/combine-schedulers/UIScheduler Defines the minimum tolerance for scheduling operations on the UIScheduler. ```swift public var minimumTolerance: SchedulerTimeType.Stride ``` -------------------------------- ### Define ImmediateSchedulerOf typealias Source: https://pointfreeco.github.io/combine-schedulers/ImmediateSchedulerOf Use this typealias to specify an ImmediateScheduler by wrapping an existing scheduler's time type and options. ```swift public typealias ImmediateSchedulerOf = ImmediateScheduler< Scheduler.SchedulerTimeType, Scheduler.SchedulerOptions > where Scheduler: Combine.Scheduler ``` -------------------------------- ### UnimplementedScheduler Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Represents a scheduler that causes the current XCTest test case to fail if it is used. This is useful for verifying that certain code paths do not rely on scheduling. ```APIDOC ## Structure `UnimplementedScheduler` ```swift public struct UnimplementedScheduler: Scheduler where SchedulerTimeType: Strideable, SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible ``` A scheduler that causes the current XCTest test case to fail if it is used. This scheduler can provide an additional layer of certainty that a tested code path does not require the use of a scheduler. ### Conforms To `Scheduler` ### Initializers #### `init(_:​now:​)` ```swift public init(_ prefix: String = "", now: SchedulerTimeType) ``` Creates an unimplemented scheduler with the given date. **Parameters** | Name | Type | Description | |--------|-------------------|----------------------------------------------------------------------------------| | prefix | `String` | A string that identifies this scheduler and will prefix all failure messages. | | now | `SchedulerTimeType` | The current date of the unimplemented scheduler. | ### Properties #### `minimumTolerance` ```swift public var minimumTolerance: SchedulerTimeType.Stride ``` #### `now` ```swift public var now: SchedulerTimeType ``` #### `prefix` ```swift public let prefix: String ``` ### Methods #### `schedule(options:​_:​)` ```swift public func schedule(options _: SchedulerOptions?, _ action: () -> Void) ``` #### `schedule(after:​tolerance:​options:​_:​)` ```swift public func schedule( after _: SchedulerTimeType, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: () -> Void ) ``` #### `schedule(after:​interval:​tolerance:​options:​_:​)` ```swift public func schedule( after _: SchedulerTimeType, interval _: SchedulerTimeType.Stride, tolerance _: SchedulerTimeType.Stride, options _: SchedulerOptions?, _ action: () -> Void ) -> Cancellable ``` ``` -------------------------------- ### UnimplementedScheduler minimumTolerance Property Source: https://pointfreeco.github.io/combine-schedulers/UnimplementedScheduler Represents the minimum tolerance for scheduling operations. For UnimplementedScheduler, this property is typically not used as scheduling itself causes a test failure. ```swift public var minimumTolerance: SchedulerTimeType.Stride ``` -------------------------------- ### Typealias TestSchedulerOf Source: https://pointfreeco.github.io/combine-schedulers/TestSchedulerOf A convenience typealias to specify a TestScheduler by the scheduler it wraps. ```APIDOC ## Typealias TestSchedulerOf ### Description A convenience typealias to specify a `TestScheduler` by the scheduler it wraps rather than by the time type and options type. ### Definition ```swift public typealias TestSchedulerOf = TestScheduler< Scheduler.SchedulerTimeType, Scheduler.SchedulerOptions > where Scheduler: Combine.Scheduler ``` ``` -------------------------------- ### Define AnySchedulerOf Typealias Source: https://pointfreeco.github.io/combine-schedulers/AnySchedulerOf A convenience typealias for specifying an AnyScheduler by the scheduler it wraps, rather than by its time and options types. Requires the wrapped scheduler to conform to Combine.Scheduler. ```swift public typealias AnySchedulerOf = AnyScheduler< Scheduler.SchedulerTimeType, Scheduler.SchedulerOptions > where Scheduler: Combine.Scheduler ```