TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Swift gems for creating reliable, concurrent OS X desktop apps

46 pointsby misterdataalmost 10 years ago

4 comments

Sidniciousalmost 10 years ago
Shameless plug for my tiny implementation of Promise (similar to the Future type mentioned in the article)[1].<p>I&#x27;ve used it in a few projects, and it makes dealing with async things feel surprisingly natural:<p><pre><code> getLocation() .then { apiRequest(params, location: $0) } .then { json -&gt; () in for result in json[&quot;results&quot;] { display(result) } } .catch { showError($0) } </code></pre> It&#x27;s also easy trivial to adapt existing callback-based[2] and delegate-based[3] APIs to promises.<p>[1]: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;93d2a8db1266e2fd239c" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;93d2a8db1266e2fd239c</a><p>[2]: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;69df2c483aadc08bda4f" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;69df2c483aadc08bda4f</a><p>[3]: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;99b099d9b6f2ecb9e383" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Sidnicious&#x2F;99b099d9b6f2ecb9e383</a>
__bbalmost 10 years ago
The Failable type in the article looks like this Result project on GitHub [1]. It makes for interesting related reading.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;antitypical&#x2F;Result" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;antitypical&#x2F;Result</a>
评论 #9679593 未加载
SeoxySalmost 10 years ago
&gt; LOGGING FROM DIFFERENT BACKGROUND THREADS AT ONCE<p>Or, you could just make a logging serial queue that you send all log messages to; that way there&#x27;s no risk of activity on the main thread slowing down your logging. In (Obj-)C:<p><pre><code> static queue_t queue; void log (NSString *message) { static dispatch_once_t onceToken; dispatch_once(&amp;onceToken, ^{ queue = dispatch_queue_create(&quot;logging&quot;, DISPATCH_QUEUE_SERIAL); }); dispatch_async(queue, ^{ NSLog(message); }); }</code></pre>
评论 #9715903 未加载
empyricalalmost 10 years ago
I seem to be getting an invalid certificate warning on this site, is this happening for anyone else?
评论 #9678784 未加载