You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 16, 2020. It is now read-only.
Debounce seems to deliver the first skipped call to update, instead of the last call to update.
I think this happens because the skipped calls to update are scheduled to be evaluated again 1) without previous skipped calls being cancelled, and 2) are scheduled to be evaluated again very close to each other temporally. Observable.delay uses DispatchQueue.asyncAfter which isn't very precise, so whichever one fires first (usually the first one scheduled in my search-as-you-type use case) will set the new lastCalled value and ignore the others.
// skip result if there was a newer result
if currentTime.compare(lastCalled!) == .orderedDescending {
let s = Observable<T>()
s.delay(seconds - timeSinceLastCall!).subscribe(updateIfNeeded(observable))
s.update(value)
}
Debounce seems to deliver the first skipped call to update, instead of the last call to update.
I think this happens because the skipped calls to update are scheduled to be evaluated again 1) without previous skipped calls being cancelled, and 2) are scheduled to be evaluated again very close to each other temporally. Observable.delay uses DispatchQueue.asyncAfter which isn't very precise, so whichever one fires first (usually the first one scheduled in my search-as-you-type use case) will set the new
lastCalledvalue and ignore the others.