DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

QueryResultCallback with List parameter

Open comann opened this issue 10 years ago • 6 comments

DBFlow Version: 3.0.0-beta6 Issue Kind (Feature): Description: Is there an existing way to create an asynchronous query that returns a list?

Existing Code:

 SQLite.select()
                    .from(CustomBaseModel.class)
                    .where(CustomBaseModel_Table.Id.eq(id))
                    .async()
                    .queryResultCallback(new QueryTransaction.QueryResultCallback<InspireColor>() {
                        @Override
                        public void onQueryResult(QueryTransaction transaction, @NonNull CursorResult<InspireColor> tResult) {
                        }
                    })
                    .execute();

Proposed Code:

  SQLite.select()
                    .from(CustomBaseModel.class)
                    .where(CustomBaseModel_Table.Id.eq(id))
                    .async()
                    .queryResultCallback(new QueryTransaction.QueryResultCallback<InspireColor>() {
                        @Override
                        public void onQueryResult(QueryTransaction transaction, @NonNull List<TResult> results) {
                        }
                    })
                    .execute();

This would help offload the time it takes to process the cursor off the main ui thread and put it in the background.

comann avatar May 03 '16 18:05 comann

I see. that makes perfect sense.

agrosner avatar May 03 '16 18:05 agrosner

Use queryListResult() method which will provide what you're lookin for :)

agrosner avatar May 03 '16 18:05 agrosner

Awesome. Thanks for the speedy reply and enhancement. Do I need to pull in the source into my project or is there a new beta release (i.e. 3.0.0-beta7)?

comann avatar May 03 '16 19:05 comann

Probably will be 3.0.0. For now you'll need to pull in develop to see the change or pull in latest commit from jitpack.io

On Tue, May 3, 2016 at 3:02 PM, Corey Mann [email protected] wrote:

Awesome. Thanks for the speedy reply and enhancement. Do I need to pull in the source into my project or is there a new beta release (i.e. 3.0.0-beta7)?

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/Raizlabs/DBFlow/issues/786#issuecomment-216631924

agrosner avatar May 03 '16 19:05 agrosner

        compile

'com.github.Raizlabs.DBFlow:dbflow:develop-3.0.0-beta6-g816c5cd-37'

On Tue, May 3, 2016 at 3:28 PM, Andrew Grosner [email protected] wrote:

Probably will be 3.0.0. For now you'll need to pull in develop to see the change or pull in latest commit from jitpack.io

On Tue, May 3, 2016 at 3:02 PM, Corey Mann [email protected] wrote:

Awesome. Thanks for the speedy reply and enhancement. Do I need to pull in the source into my project or is there a new beta release (i.e. 3.0.0-beta7)?

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/Raizlabs/DBFlow/issues/786#issuecomment-216631924

agrosner avatar May 03 '16 19:05 agrosner

ensure you use same version on all pieces of dbflow

agrosner avatar May 03 '16 19:05 agrosner