Grand Central Dispatch (GCD) function they can utilize but once it's set up, these calls can not be easily cancelled.
How could we stop it such as a custom method "cancellable_dispatch_after"
If you are trying to find a way to cancel asynchronous operations using GCD, you should use DispatchWorkItem
. It allows you to do the following:
import Dispatch
let task = DispatchWorkItem {
//Do some stuff
}
DispatchQueue.main.async(execute: task)
task.cancel()
Obviously, you wouldn't do this exactly, but I believe it shows how to do what you want.
Hope this helps!