Slide 18
Slide 18 text
Flux(Action: ίʔυྫ)
class TopAction {
enum Item {
case load
case error
}
private let dispatcher: Dispatcher
init(dispatcher: Dispatcher = .shared) {
self.dispatcher = dispatcher
}
func loadItem() {
let request = QiitaAPI.ItemRequest()
Session.send(requeset) { result in
switch result {
case .success(let items):
self.dispatcher.dispatch(obj: items, key: Item.load)
case .failure(let error):
self.dispatcher.dispatch(obj: error, key: Item.error)
}
}
}
}