Kron
public class Kron : NSObject
Kron is a NSTimer manager offering 4 modes through a unified api. Kron takes care of the involved implementation of NSTimers while ensuring a proper memory management with no extra effort:
Kron.debounce: Calls immediatly and reject calls until time out elapsesKron.debounceLast: Asdebouncebut also performs the last call after time outKron.idle: Performs the last call after not being called during the timeout intervalKron.watchdog: Asidlebut allowing to be canceled withwatchDogCancel
-
Creates both a
debounceand idleidletimer.- The function will debounce actions as defined in
interval - Additionally will ensure to perform the last call after timeout
Timer will be reset if called again with the same
KronKey
Declaration
Swift
public static func debounceLast( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
- The function will debounce actions as defined in
-
Creates a
debouncetimer.- The function will debounce actions as defined in
interval Timer will be reset if called again with the same
KronKey
Declaration
Swift
public static func debounce( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
- The function will debounce actions as defined in
-
Creates a
watchdogtimer.- Use
watchdogCancelto early abort the timer. - The function will be called after timeout.
Timer will be reset if called again with the same
KronKey
Declaration
Swift
public static func watchDog( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
- Use
-
Creates an
idletimer.- The function will be called after timeout.
Timer will be reset if called again with the same
KronKey
Declaration
Swift
public static func idle( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
-
Creates both a
debounceand idleidletimer.- The function will debounce actions as defined in
interval - Additionally will ensure to perform the last call after timeout
Timer will be reset if called again with the same
KronKey
Declaration
Swift
public func debounceLast( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
- The function will debounce actions as defined in
-
Creates a
debouncetimer.- The function will debounce actions as defined in
interval Timer will be reset if called again with the same
KronKey
Declaration
Swift
public func debounce( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, _ action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
- The function will debounce actions as defined in
-
Creates a
watchdogtimer.- Use
watchdogCancelto early abort the timer. - The function will be called after timeout.
Timer will be reset if called again with the same
KronKey
Declaration
Swift
public func watchDog( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, _ action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
- Use
-
Creates an
idletimer.- The function will be called after timeout.
Timer will be reset if called again with the same
KronKey
Declaration
Swift
public func idle( timeOut interval:Double, resetKey aKey:KronKey, context:Any? = nil, _ action:@escaping KronClosure)Parameters
intervalthe timeOut interval
aKeyan String or Class
contextany Struct or Class. (Internally wraped as a weak reference)
actionclosure called on timeout
View on GitHub
Kron Class Reference