Skip to content

Commit

Permalink
Undeprecate debounce and throttle overloads restored in 1.1.0 (#2392)
Browse files Browse the repository at this point in the history
* Undeprecate debounce and throttle overloads restored in 1.1.0

* Apply suggestions from code review

---------

Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
pyrtsa and stephencelis authored Aug 22, 2023
1 parent 974fb9f commit 9f4202a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import Combine

@available(
*,
deprecated,
message: "Use 'withTaskCancellation(id: _, cancelInFlight: true)' in 'Effect.run', instead."
)
extension EffectPublisher {
/// Turns an effect into one that can be debounced.
///
Expand Down Expand Up @@ -63,6 +58,14 @@ extension EffectPublisher {
/// - scheduler: The scheduler you want to deliver the debounced output to.
/// - options: Scheduler options that customize the effect's delivery of elements.
/// - Returns: An effect that publishes events only after a specified time elapses.
@available(
*,
deprecated,
message:
"""
Types defined for cancellation may be compiled out of release builds in Swift and are unsafe to use. Use a hashable value, instead, e.g. define a timer cancel identifier as 'enum CancelID { case debounce }' and call 'effect.debounce(id: CancelID.debounce, …)'.
"""
)
public func debounce<S: Scheduler>(
id: Any.Type,
for dueTime: S.SchedulerTimeType.Stride,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Combine
import Dispatch
import Foundation

@available(*, deprecated)
extension EffectPublisher {
/// Throttles an effect so that it only publishes one output per given interval.
///
Expand Down Expand Up @@ -80,6 +79,14 @@ extension EffectPublisher {
/// `false`, the publisher emits the first element received during the interval.
/// - Returns: An effect that emits either the most-recent or first element received during the
/// specified interval.
@available(
*,
deprecated,
message:
"""
Types defined for cancellation may be compiled out of release builds in Swift and are unsafe to use. Use a hashable value, instead, e.g. define a timer cancel identifier as 'enum CancelID { case throttle }' and call 'effect.throttle(id: CancelID.throttle, …)'.
"""
)
public func throttle<S: Scheduler>(
id: Any.Type,
for interval: S.SchedulerTimeType.Stride,
Expand Down

0 comments on commit 9f4202a

Please sign in to comment.