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

Can't query with defer #1734

Closed
epolar opened this issue Aug 16, 2022 · 2 comments
Closed

Can't query with defer #1734

epolar opened this issue Aug 16, 2022 · 2 comments

Comments

@epolar
Copy link

epolar commented Aug 16, 2022

DBFlow Version: 5.0.0-alpha2

Bug or Feature Request: defer is suspend, is my code fault?

Description:
code on my repository:

    fun getDefaultPaymentAsync(): Deferred<Payment?> {
        return (select from Payment::class
                where (Payment_Table.is_delete.`is`(false))
                orderBy OrderBy.fromProperty(Payment_Table.is_default).descending()
                orderBy OrderBy.fromProperty(Payment_Table.last_modify_time).descending()
                ).async(database) { d -> querySingle(d) }
            .defer()
    }

code how I use it:

        runBlocking {
            PaymentRepository
                .getDefaultPaymentAsync()
                .await().let { setPayment(it) }  // suspend here, setPayment never be invoke.
         }
@loquitowen
Copy link

loquitowen commented Aug 16, 2022 via email

@epolar epolar changed the title how can query with defer Can't query with defer Aug 16, 2022
@epolar
Copy link
Author

epolar commented Aug 21, 2022

My fault, I should use GlobalScope.launch not runBlocking.

@epolar epolar closed this as completed Aug 21, 2022
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

No branches or pull requests

2 participants