Commit Graph

2 Commits

Author SHA1 Message Date
Kenta Aikawa
5b4f00240b Fix some docs (#2498)
* Delete unnecessary block

* Fix debounce document
2023-10-05 09:49:22 -04:00
Stephen Celis
ee3e96ce10 Bring back debounce? (#2372)
Having brought back an explicit interface for `throttle`
[here](https://github.com/pointfreeco/swift-composable-architecture/pull/2368)
we should also consider providing an explicit interface for `debounce`.

Though a clock-based debounce is a matter of:

```swift
return .run { send in
  try await withTaskCancellation(id: CancelID.debounce) {
    try await clock.sleep(for: .seconds(1))
    await send(.action)
  }
}
```

A dedicated operator simplifies and flattens:

```swift
return .send(.action)
  .debounce(id: CancelID.debounce, for: .seconds(1), clock: clock)
```

This PR only brings back the scheduler-based API, so alongside #2368 we
are reintroducing two Combine-forward APIs for this work. Before
we release a 1.1 that fully commits these APIs, we should consider if we
can make clock-based APIs work, instead (or in addition). If in
addition, we should also consider introducing the Combine-based APIs as
soft-deprecated to begin with.
2023-08-14 09:38:37 -07:00