Conversation
|
|
||
| strongSelf.doRenderAndDiff(newSections, animated: animated, animations: animations, completion: completion) | ||
| } | ||
| renderAndDiffQueue.operations.forEach { (operation) in |
There was a problem hiding this comment.
renderAndDiffQueue.operations.lazy.filter { !$0.isExecuting }.forEach { $0.cancel() }
There was a problem hiding this comment.
Won’t this iterate over the array twice instead of once? Why lazy?
There was a problem hiding this comment.
lazy makes it iterate over elements only once :)
["A", "B", "CD", "EF"].lazy.filter {
print("filter")
return $0.count > 1
}.forEach {
print("forEach")
$0.lowercased()
}
spits out:
filter
filter
filter
forEach
filter
forEach
There was a problem hiding this comment.
(but I don't actually care, lazy is pretty cool though and makes for nice functional code without losing efficiency)
|
What should we do about the callbacks passed in? There was a discussion about this before and I'm not sure it was resolved. Would there be any value in calling the completion block with some type of status enum (done, cancelled, failed?). The goal would be to provide more context to the callback to react to the completion accordingly? Just a thought. |
|
The completion callbacks are still called on cancelled operations. |
|
You should make a release 😜 (update the CHANGELOG, tag the framework) |

In some situations operations can pile up in the renderAndDiff queue. It's not necessary to run all of them because the last one added should provide the correct state to display. This PR cancels any outstanding operations that are not already executing before adding the new operation to the queue.