Closed kostiakoval closed 8 years ago
What's the purpose of this?
Clean code. I didn't want to include extra lib like Async So made this simple API
I would advise against using syntax-slimming wrappers that add no extra functionality because clean code is not exclusively about syntax styling. You'll come to realise (sooner or later) that clean code is not only about how easy it is to read, but also how clear it is for you and other developers to understand (and extract what is being achieved).
I agree, but getting familiar with 1 line of code is very easy. GCD API looks very bad in swift
Maybe for you, but for existing (and new) contributors, they will have to adopt your syntax-slimmer (for consistency) when they need to interact with the GCD API. If your only concern is syntax, consider using NSOperation
(as that's an Apple API that wraps GCD plus adds more functionality).
At the end of the day, I am just sharing knowledge. What you do with it is entirely up to you. My team and I tend to avoid small syntax wrappers because they simply create ambiguity and increase the amount of dependencies for no good reason.
Thanks for sharing your thoughts. NSOperation
adds much more complexity, I wound't use it here
For me it's all about tradeoffs - Learning curve vs Using benefits. It takes 1 min to learn the GCD.main
API but it makes code much cleaner and it also clear what it does. For me benefits are bigger that .
That's just my opinion :)
I agree that NSOperation
adds a lot more complexity, but it also offers cleaner syntax. I think we should stick with dispatch_async(dispatch_get_main_queue())
, but it's not my place to say. Hopefully @nixzhu has something to say.
Clean Async code