hpique / articles Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Thank you for sharing this recommendation:
I use lots of onSuccess / onFailure blocks in my network code and it was good to find this analysis.
Unfortunately, an important part of style is: how is everyone else expected to interpret this? May I recommend inclusion of any well known examples in the wild which are currently using this prescribed style.
The page is written for "Xcode 6.1 Beta 2".
New versions of Swift have since been released and the information may not be accurate anymore.
Fetching an image is a poor example of an action which you would react to neither upon success nor failure. A better example may be posting an update or sending a ping.
Also, the example seems contrived when there is a check for success == nil && failure == nil for posting an image. A real world application would never do this.
It is stated:
When performance is a concern, better to use
nil
as a default value.
There is no proof presented that not executing a nil closure is faster than executing an empty closure.
If such proof does not exist, a better statement might be:
If parts of the function may be skipped when closures are not provided then it is better to use
nil
as a default value.
Here is an example of a chaining return that you are talking about.
https://gist.github.com/fulldecent/6d64f86869e5d9d12436
Right now it only supports async. But it is possible to also work with sync returns.
It IS possible to keep this generic! And this implementation works everywhere.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.