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

Fix Pending Status persists for all successful transactions #989

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

GibsonRuitiari
Copy link
Contributor

This PR fixes the pending status that persists after all successful transactions.

Fixes #965 and #961🦕

Copy link
Member

@jumaallan jumaallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting fix 👏🏽

@jumaallan jumaallan added this pull request to the merge queue Mar 27, 2023
Merged via the queue into UseHover:main with commit 7c732a8 Mar 27, 2023
@GibsonRuitiari
Copy link
Contributor Author

A little explanation for future persons :-)

When your app components create different instances of a Dao, the instances are not synchronized. Hence you might find that one instance of your Dao is busy updating the database whereas another is busy reading the database. So the one reading the database might in most cases get stale data.

One solution could be providing a singleton instance of your Dao and injecting the instance to all your components. Since you only have one single instance, from how room is designed, it will be up-to-date with the current data in the table.

Another solution could be forcing room to invalidate table instances and subsequently invalidate your Dao instances upon an update so that any component using your Dao will get an updated instance of it. Behind the scenes what room does is it uses a service that tracks the database changes and updates the instances of your Dao's. So anytime your data changes, the instances are updated and the Dao's are always synchronized.

I have gone with the second solution since it is the easier one.

@jumaallan
Copy link
Member

A little explanation for future persons :-)

When your app components create different instances of a Dao, the instances are not synchronized. Hence you might find that one instance of your Dao is busy updating the database whereas another is busy reading the database. So the one reading the database might in most cases get stale data.

One solution could be providing a singleton instance of your Dao and injecting the instance to all your components. Since you only have one single instance, from how room is designed, it will be up-to-date with the current data in the table.

Another solution could be forcing room to invalidate table instances and subsequently invalidate your Dao instances upon an update so that any component using your Dao will get an updated instance of it. Behind the scenes what room does is it uses a service that tracks the database changes and updates the instances of your Dao's. So anytime your data changes, the instances are updated and the Dao's are always synchronized.

I have gone with the second solution since it is the easier one.

Thanks for this 👏🏽

@as7r44
Copy link

as7r44 commented Mar 29, 2023

Hello guys,
was this fix merged with main branch or tested and working fine with you ?
As still I am facing this challenge of pending status on successfull transactions

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

Successfully merging this pull request may close these issues.

3 participants