This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // reference: https://www.swiftbysundell.com/articles/delaying-an-async-swift-task/ | |
| let loadingSpinnerTask = Task.delayed(byTimeInterval: 0.15) { | |
| self.showLoadingSpinner() | |
| } | |
| Task { | |
| await a() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // < iOS 16 | |
| var task: Task<(), Never>? | |
| func debounce(seconds: Double = 1.0, | |
| operation: @escaping () -> Void) { | |
| task?.cancel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // < iOS 16 | |
| var task: Task<(), Never>? | |
| func delay(seconds: Int = 1, | |
| operation: @escaping () -> Void) { | |
| task = Task { | |
| do { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // reference: https://stackoverflow.com/questions/67978028/maximum-number-of-threads-with-async-await-task-groups | |
| func run() async { | |
| await withTaskGroup(of: Void.self) { group in | |
| for i in 0 ..< 32 { | |
| group.addTask { | |
| print(await fire(i)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // >= iOS 16 | |
| var task: Task<(), Never>? | |
| func delay(interval: Duration = .seconds(1), | |
| operation: @escaping () -> Void) { | |
| task = Task { | |
| do { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // >= iOS 16 | |
| var task: Task<(), Never>? | |
| func debounce(interval: Duration = .nanoseconds(10000), | |
| operation: @escaping () -> Void) { | |
| task?.cancel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // debounce-throttle.swift | |
| // | |
| // Created by Simon Ljungberg on 19/12/16. | |
| // License: MIT | |
| // | |
| import Foundation | |
| extension TimeInterval { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| precedencegroup ForwardPipe { | |
| associativity: left | |
| } | |
| infix operator |> : ForwardPipe | |
| func |> <V, F>(v: V, f: ((V) -> F)) -> F { | |
| f(v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default "123"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Clojure macro & homoiconicity (LISP) for newbies | |
| ;; | |
| ;; This is personal study note | |
| ;; | |
| ;; Disclaimer: | |
| ;; Here I am trying to guide the high level of overview of macro & homoiconicity based on Clojure. | |
| ;; I cannot say these will be 100% accurate, since I am also still in the middle of getting LISP and Clojure, | |
| ;; but at least I believe it could portray the big picture | |
| ;; rather than the technical detail inside, providing links of blogs and articles I found useful. | |
| ;; Please do your own research when in doubt if interested further by using this as the guidance. |