I would like to handle text changes and filter some collection via List. I would like to wait until user does pause on input and then make filtration operation. I would like to make it using .throttle
operator in Effect
of TheComposableArchitecture
without Task.sleep
. I have such solution:
return .run { [items = state.items, query = state.query] send in
try await Task.sleep(nanoseconds: Constant.MY_DELAY)
await send(.filterItems(items.filter(by: query)))
}
.cancellable(id: CancelID.search, cancelInFlight: true)
This solution works, but I would like to make it using .throttle