Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Fixed issues with error and main tread
Browse files Browse the repository at this point in the history
  • Loading branch information
sladan-hedvig committed Nov 29, 2023
1 parent ddc03f8 commit be9b5fb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions Presentation/PresentableStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,29 +323,29 @@ open class LoadingStateStore<State: StateProtocol, Action: ActionProtocol, Loadi
}

public func removeLoading(for action: Loading) {
loadingStates.removeValue(forKey: action)
loadingWriteSignal.value = loadingStates
DispatchQueue.main.async {[weak self] in guard let self = self else { return }
self.loadingStates.removeValue(forKey: action)
self.loadingWriteSignal.value = self.loadingStates
}
}

public func setLoading(for action: Loading) {
loadingStates[action] = .loading
DispatchQueue.main.async {[weak self] in guard let self = self else { return }
self.loadingStates[action] = .loading
}
}

public func setError(_ error: String, for action: Loading){
loadingStates[action] = .error(error: error)
DispatchQueue.main.async {[weak self] in guard let self = self else { return }
self.loadingStates[action] = .error(error: error)
}
}

public func reset() {
loadingStates.removeAll()
DispatchQueue.main.async {[weak self] in guard let self = self else { return }
loadingStates.removeAll()
}
}
//
// public func setLoadingState(for action: Loading, state: LoadingState<String>?) {
// if let state {
// loadingStates[action] = state
// } else {
// loadingStates.removeValue(forKey: action)
// }
// }

public required init() {
super.init()
Expand Down

0 comments on commit be9b5fb

Please sign in to comment.