Closed ShotaKashihara closed 4 years ago
今日は @nowperson も参加します!
https://www.cocoawithlove.com/blog/twenty-two-short-tests-of-combine-part-1.html
他のリアクティブプログラミングフレームワークを利用した際に問題になるエッジケースをCombineフレームワークがどのように扱っているかを調べた結果
利用しているextension https://github.com/mattgallagher/CombineExploration/blob/master/Sources/CombineExploration/Subject%2BSend.swift https://github.com/mattgallagher/CombineExploration/blob/master/Sources/CombineExploration/Subscribers%2BEvent.swift
https://www.avanderlee.com/swift/combine-error-handling/
mapError
で上がったErrorから適切なErrorにマップできる。
let cancellable = imageURLPublisher.flatMap { requestURL in
return URLSession.shared.dataTaskPublisher(for: requestURL)
.mapError { error -> RequestError in
return RequestError.sessionError(error: error)
}
}.sink(receiveCompletion: { (error) in
print("Image request failed: \(String(describing: error))")
}, receiveValue: { (result) in
let image = UIImage(data: result.data)
})
// Fetches the image successfully.
imageURLPublisher.send(URL(string: "https://httpbin.org/image/jpeg")!)
// Prints: Image request failed: RequestError.sessionError(error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found."
imageURLPublisher.send(URL(string: "https://unknown.url/image")!)
let notFoundImage: UIImage? = UIImage()
let imageURLPublisher = PassthroughSubject<URL, RequestError>()
let cancellable = imageURLPublisher.flatMap { requestURL in
return URLSession.shared.dataTaskPublisher(for: requestURL)
.mapError { error -> RequestError in
return RequestError.sessionError(error: error)
}
}.map({ (result) -> UIImage? in
return UIImage(data: result.data)
}).catch({ (error) -> Just<UIImage?> in
return Just(notFoundImage)
}).sink(receiveValue: { (image) in
_ = image
})
imageURLPublisher.send(URL(string: "https://httpbin.org/image/jpeg")!)
https://github.com/Cosmo/HackMan
Sourcery みたいなボイラーテンプレート生成ツール
@propertyWrapper
を使った自作 PropertyWrapper の例
https://github.com/apple/swift-evolution/blob/master/proposals/0258-property-wrappers.md#examples
https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol
Why
Where
Pearl Jam (Subject to change)
5F, MG Shirokanedai Building (Wantedly, Inc. Tokyo HQ)
Who
You are working for Wantedly? Sure, you can join anytime. If not, you need to contact us first. Or, you can "want to visit" the meetup, which you can find in www.wantedly.com/companies/wantedly/projects.
What
You write topics like below contents and we talk about these on the meetup. Every participant needs to write one topic at least.
Also, you can find new topics from the newsletters:
How
・・・
参加者は開催までに話したいことを少なくとも1トピックをコメントしましょう。 ネタ被りを避けるために、まずはタイトルだけでコメントすることを推奨します。 より多くの学びを得るためにどんな内容でもアウトプットを歓迎します!😊
cc/ @wantedly/ios
Edit this template
Previous issue
https://github.com/wantedly/ios_night/issues/62