Skip to content

Remove single value buffer from AsyncSequence implementation #208

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rickclephas
Copy link
Owner

Only the first emitted value needs to be buffered. Once we have consumed the first value we can wait for a call to Iterator.next before invoking the next callback from Kotlin.
This will make sure that emit in Kotlin suspends until Swift calls Iterator.next to get the next value.

We could even delay the Flow collection until the first call to Iterator.next.
Which would allow us to remove the item buffer completely.
Although in that case we'll need a fatalError for the nil check on continuation.

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.

1 participant