duemunk / Async

Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch
MIT License
4.59k stars 316 forks source link

Why dont support dispatch_once? #48

Closed huynhphan89 closed 9 years ago

huynhphan89 commented 9 years ago

Hi,

You said "I've found no need for dispatch_once in Swift" in #2 . Could you please explain why no need to use dispatch_one in Swift?

Thanks.

josephlord commented 9 years ago

Global variable (and constants) plus static members of classes/structs/enums with inital values basically initialised with the same dispatch once guarantees. And you can let the inital value be the result of a closure if you need any complex set up.

duemunk commented 9 years ago

@huynhphan89 What @josephlord said. If you have a specific use of dispatch_once in Swift, feel free to share :)