-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
ContentResolver query Observable #71
Comments
Speaking of emitting cursor rows, what do u think of wrapping the cursor with |
Seems like a needless allocation. It also doesn't handle closing.
|
I think the Iterator wrapper for Cursor is great. That's what we do in |
How about something like https://gist.github.com/pieces029/076ddfe7122fd78da5a3? |
So basically we want an Observable that emits an Iterable once and before completing closes the Cursor? |
No it's just an adapter. As per the duality principle, anything that's |
@mttkay then if we do that then something like Observable.from(new IterableCursor(cursor)) will emit the Cursor already while it has next. With that said, all we need to do is close the cursor with something like:
Same for error so we always close the Cursor... Did I follow you correctly? I guess our ContentObservables.query(..) could compose the Observable and add the closing cursor part there? |
At Venmo we worked on an IterableCursor library, feel free to check it out https://github.com/venmo/cursor-utils. It works well with Rx, as it will emit regular |
@ronshapiro nice, I wrote almost the exact same thing for our storage abstraction |
Shouldn't the examples above use |
This has been removed as part of #172 for a future release. Consider building on SqlBrite's ability to query a content resolver (not that I'm biased...). |
I'm wondering if |
Nothing about |
Yeah, I was thinking that too. Add it to RxJava? |
This is a proposal to implement an Observable that emits a Cursor while the Cursor has next and then closes the Cursor upon completion or failure.
This sounds like something useful that I can contribute with and I would like to hear thoughts before putting something together?
Something like:
ContentObservables.query(PROJECTION, SELECTION, ...).subscribe(
...
onNext(Cursor c) { // Calls once for each position in the cursor };
...
);
The text was updated successfully, but these errors were encountered: