Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Hydra_Internals_4.swift
private func set(state newState: State<Value>) {
self.stateQueue.sync {
guard self.state.isPending else {
return
}
self.state = newState // change state
self.observers.forEach { observer in
switch (state, observer) {
case (.resolved(let value), .onResolve(_,_)):
observer.call(andResolve: value)
case (.rejected(let error), .onReject(_,_)):
observer.call(andReject: error)
default:
break
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment