Slide 46
Slide 46 text
query.rx_text
// 1. 3จࣈҎ্
.filter {string in
return string.characters.count > 3
}
// 2. ࠷ޙͷೖྗ͔Β0.51ඵܦա
.debounce(0.51, scheduler: MainScheduler.instance)
// 3. ϦΫΤετΛੜ
.map {string in
let apiURL = NSURL(string:
"https://api.github.com/q?=" + string)!
return NSURLRequest(URL: apiURL)
}
// 4. ϦΫΤετΛ࣮ߦʢඇಉظ௨৴ʣ
.flatMapLatest { request in
return NSURLSession.sharedSession().rx_data(request)
}
// 5. ϦΫΤετ݁ՌΛJSONΦϒδΣΫτʹม
.map { data —> Array in
let json = try NSJSONSerialization.JSONObjectWithData(
data, options: [])
return json as! Array
}
// 6. RepoΦϒδΣΫτʹม
.map {object in
return Repo(object: object)
}
// 7. RepoΦϒδΣΫτΛTableViewʹө
.bindTo(tableView.rx_itemsWithCellIdentifier("Cell"))
iOSΞϓϦ։ൃʹ͓͚ΔRxSwiftͷ׆༻ (※ ίʔυrxswift-2.0)