I have the results from a publisher in an Effect<[Int], Error>
How do I assign that [Int] to a variable?
Although I am able to get the results using this:
case .reviewed:
return environment.networkQuery.reviewed(pageCount: 1)
.catchToEffect()
.map(BespokeAction.processQueryResults)
case let .processQuestionResult(.success(ids)):
...
case let .processQuestionResult(.failure(error)):
print(error)
...
I want to use the publisher outside of the reducer:
let values: Effect<[Question], Error> = environment.networkQuery.reviewed(pageCount: 1)
what do I do to values
to extract the array upon success?
note: this a more finely resolved take on a question I posted previously:
Although the code was mostly good, I never saw the results.
This is because the code is inside a function and cancellable was disappearing with the function returning. The publisher immediately stops when the cancellable goes out of scope.
I moved
results
andreturnValues
into the view and now update a@State
property in thereceiveValue
closure: