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
: Asdebounce
but also performs the last call after time outKron.idle
: Performs the last call after not being called during the timeout intervalKron.watchdog
: Asidle
but allowing to be canceled withwatchDogCancel
-
Creates both a
debounce
and idleidle
timer.- 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
- The function will debounce actions as defined in
-
Creates a
debounce
timer.- 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
- The function will debounce actions as defined in
-
Creates a
watchdog
timer.- Use
watchdogCancel
to 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
- Use
-
Creates an
idle
timer.- 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
-
Creates both a
debounce
and idleidle
timer.- 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
- The function will debounce actions as defined in
-
Creates a
debounce
timer.- 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
- The function will debounce actions as defined in
-
Creates a
watchdog
timer.- Use
watchdogCancel
to 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout
- Use
-
Creates an
idle
timer.- 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
interval
the timeOut interval
aKey
an String or Class
context
any Struct or Class. (Internally wraped as a weak reference)
action
closure called on timeout