I want to fire two publishers but second should only fire when first one is complete. I tried it with zip could not achieve it. Following is my code:
let resetPasscodeConfirmationPublisher = authUseCase.resetPasscodeConfirmation(phoneNumber: phoneNumber, code: pincode, passcode: passcode)
let getAuthTokenPublisher = authUseCase.getAccessToken(passcode: passcode)
resetPasscodeConfirmationPublisher.zip(getAuthTokenPublisher).sink { res in
print(res)
} receiveValue: { values in
print(values.0)
print(values.1)
}.store(in: &cancellables)
so first, resetPasscodeConfirmationPublisher should run and when it is done and I get some value from it getAuthTokenPublisher should run. Right now I am getting response from getAuthTokenPublisher only and not from the first publisher.
2
Answers
You can use a map operator to do that
This can help? I don’t sure to understand the question but I think you can start the second publisher on
receiveCompletion
of first publisher.