Hydra_Internals_3.swift
internal func runBody() { | |
self.stateQueue.sync { | |
if state.isPending == false || bodyCalled == true { | |
return | |
} | |
bodyCalled = true | |
self.context.queue.async { | |
do { | |
// body can throws and fail. throwing a promise's body is equal to | |
// reject it with the same error. | |
try self.body?( { value in | |
self.set(state: .resolved(value)) // resolved | |
}, { err in | |
self.set(state: .rejected(err)) // rejected | |
}) | |
} catch let err { | |
self.set(state: .rejected(err)) // rejected (using throw) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment