Skip to content

Commit

Permalink
添加呼叫 Delegate 時 使用 Main Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
nick6969 committed Apr 7, 2018
1 parent 1c46ea2 commit 6b16861
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions MVVM/Base/Protocol/ViewModelMultipleContentDataProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ extension ViewModelLoadingProtocol where Self: ViewModelMultipleContentDataProto
case .initialize, .loadFail:
status = .loadStart
if models.isEmpty {
loadingStatusDelegate?.showLoading(true)
DispatchQueue.main.async {
self.loadingStatusDelegate?.showLoading(true)
}
}
loadData()

Expand All @@ -66,8 +68,11 @@ extension ViewModelLoadingProtocol where Self: ViewModelMultipleContentDataProto

case .refreshLoading:
status = .loadStart
models = []
loadingStatusDelegate?.showLoading(true)
if models.isEmpty {
DispatchQueue.main.async {
self.loadingStatusDelegate?.showLoading(true)
}
}
loadData()

case .loadStart, .loadMoreStart, .noMoreCanLoad:
Expand Down

0 comments on commit 6b16861

Please sign in to comment.