Skip to content

A cancellable copy of the DispatchQueue.asyncAfter function

License

Notifications You must be signed in to change notification settings

nrbrook/DispatchAfterCancellable

Repository files navigation

Introduction

The built in dispatch after function does not allow the call to be cancelled. This prevents the block being called if cancelled through the use of tokens.

Installation

Add the swift file to your project

Usage

let t = DispatchQueue.main.asyncAfterC(deadline: DispatchTime(timeIntervalSinceNow: 10), execute: { 
    print("Executed 1")
})

// cancel

DispatchQueue.asyncAfterCCancel(token: t)

About

A cancellable copy of the DispatchQueue.asyncAfter function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages