Skip to content
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

Draft
wants to merge 11 commits into
base: trunk
Choose a base branch
from
Draft

Try adding Combine again #396

wants to merge 11 commits into from

Conversation

jkmassel
Copy link
Contributor

No description provided.

paramsPublisher.send(nextPageParams) // Kick off the paramsPublisher again
} else { // Otherwise we're done
paramsPublisher.send(completion: .finished) // And paramsPublisher is complete
}
Copy link
Contributor

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.
}

Base automatically changed from parse_as_response_type to trunk November 20, 2024 01:33
@jkmassel jkmassel force-pushed the add/combine branch 3 times, most recently from 6d160a1 to ca5a180 Compare November 27, 2024 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants