-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try adding Combine again #396
base: trunk
Are you sure you want to change the base?
Conversation
paramsPublisher.send(nextPageParams) // Kick off the paramsPublisher again | ||
} else { // Otherwise we're done | ||
paramsPublisher.send(completion: .finished) // And paramsPublisher is complete | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Publishers are supposed to be "pure", without side-effect. I think that's broken by this handleEvents
code here.
For example, both sink calls in the code below should return the exact same result:
let publisher = [1, 2, 3].publisher
publisher.sink { ... } // Output: 1, 2, 3
DispatchQueue.global.asyncAfter(.now + .senconds(3)) {
publisher.sink { ... } // Output: 1, 2, 3
}
If you swap the publisher
to be let publisher = recursivePublisher(...)
, the sink
calls would behave differently. (I didn't run the code, please correct me if I'm wrong).
let publisher = recursivePublisher(...)
publisher.sink { ... } // Output: API call result.
// 3 Seconds later, after the above API call finishes.
DispatchQueue.global.asyncAfter(.now + .senconds(3)) {
publisher.sink { ... } // Unexpected: No element will be emitted here.
}
6d160a1
to
ca5a180
Compare
ca5a180
to
3046c6f
Compare
No description provided.