-
Notifications
You must be signed in to change notification settings - Fork 0
Performing database operations in background thread
Devrath edited this page Jun 11, 2021
·
2 revisions
- Database query operations take a long time to perform the background operations.
- There is the possibility that during this time UI thread may freeze and possibly it might crash.
- We can perform the operations by manually creating a separate thread. But
co-routinesare supported by theroomthat offers to thread. - We just add the
suspendkeyword and the threading is handled byroom
-
Flowis an observable API. - When we update the table in the database. We get a new list once the database updated.
- It is a kind of observable design pattern.
- Basically it has two parts.
-
Flow-> Producer Side. -
Flow Collector-> Consumer Side.
-
-
Ex: consider we have a list of students in the database. We will add a new entry to the database. We don't need to fetch a new list of students, Flow enables us to perform this automatically.