FranticApparatus是用Swift实现的Promises/A+。
示例:
func fetchLinks(reddit: String) -> Promise<[Link]> { let url = NSURL(string: baseURL + "/r/" + reddit + ".json") return fetchJSON(url).when({ (data: NSData) -> Result<NSDictionary> in return .Deferred(parseJSON(data)) }).when({ (json: NSDictionary) -> Result<[Link]> in return .Deferred(mapLinks(json)) })}
评论