Created
May 5, 2020 11:47
-
-
Save freshtonic/8c98c123a5c88853f4dc0b710b6ecb56 to your computer and use it in GitHub Desktop.
Only runs first Future
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func setupScript(tag: NFCISO7816Tag) -> AnyPublisher<CommandResult, Error> { | |
return Deferred { Future<CommandResult, Error> { promise in | |
print("C 1"); | |
tag.sendCommand(apdu: commandWriteDataUrlTemplate(), completionHandler: commandCallback(promise)) | |
}}.flatMap { _ in | |
return Deferred{ Future<CommandResult, Error> { promise in | |
print("C 2"); | |
tag.sendCommand(apdu: commandAuthenticateEV2FirstPart1(), completionHandler: commandCallback(promise)) | |
} | |
}}.flatMap { result in | |
return Deferred { Future<CommandResult, Error> { promise in | |
print("C 3"); | |
tag.sendCommand(apdu: commandAuthenticateEV2FirstPart2(result), completionHandler: commandCallback(promise)) | |
}} | |
} | |
.eraseToAnyPublisher() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment