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

Observable.fromIterator needs an optional onFinish callback #158

alexandru opened this Issue Jun 6, 2016 · 1 comment


None yet
1 participant
Copy link

alexandru commented Jun 6, 2016

Observable.fromIterator needs an optional onFinish callback to be supplied for resource deallocation. This is because the Iterator interface isn't rich enough to include canceling of a connection, which means that in case of something that keeps a file or socket handle open, like say, a database query or a file input stream, then the Iterator provides no means for closing that handle without fully traversing it.

Or in other words Observable.fromIterator should be sufficient for reading a Java InputStream, which should include calling InputStream.close() on canceling it or when an error happens. And currently this can't be done with any of the Observable operators, because of the asynchronous, laissez-faire nature of the Cancelable.cancel() in fromIterator.

So the following override of fromIterator is provided:

def fromIterator[A](iterator: Iterator[A], onFinish: () => Unit): Observable[A]

@alexandru alexandru added this to the 2.0 milestone Jun 15, 2016

@alexandru alexandru self-assigned this Jun 15, 2016


This comment has been minimized.

Copy link
Member Author

alexandru commented Jun 15, 2016

Released in 2.0-RC6

@alexandru alexandru closed this Jun 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.