Why?
Sometimes we would like to test some non-published variable values based on given time.
Example:
apiClient.fetchQuestions()
.receive(on: scheduler)
.sink { [weak self] completion in
switch completion {
case .finished:
print("finished fetching info")
case .failure(let error):
// Lets assume error message is not published value and need to be tested at certain given time.
self?.errorMessage = error.localizedDescription
}
} receiveValue: { [weak self] response in
self?.questions = response.questions
}
.store(in: &cancellables)
Now with advance(to:) function we can easily verify the value of variables at given time.
Why? Sometimes we would like to test some non-published variable values based on given time.
Example:
Now with advance(to:) function we can easily verify the value of variables at given time.