If two promise calls are consecutive, theirs then & always block never get called
Opened this issue · 0 comments
anhduyleatiheart commented
viewModel.load() method:
func load() -> Promise<ContentDirectory>? {
...
return .success(playlistDirectory)
}, queue: DispatchQueue.main)
}, queue: .main)
.then({ obj in
return .success(obj)
}, always: { [weak self] in
self?.promise = nil
}, queue: DispatchQueue.main)
return promise
}
View Controller method:
private func loadModel() {
loadCancelToken?.cancel()
guard let promise = viewModel.load() else { return }
showWaitCursorAtCenter()
loadCancelToken = promise.then({ [weak self] _ in
...
}, always: { [weak self] in
...
}, queue: DispatchQueue.main)
}
When loadModel
method is called twice in a row and the promises are fulfilled, both loadModel
's then
& always
blocks from both calls never hit the breakpoint and never get called.
View Model load()
's then
& always
blocks from both calls did get called though