使用GreenDao实现事件监听器/观察者模式

时间:2021-08-03 20:04:37

I am using GreenDao to maintain database. I am fetching data from two tables and displaying it in ListView. I want to implement event listener or Observer pattern so that I can refresh the UI whenever there is a change (insert, delete or update) in the database.

我正在使用GreenDao来维护数据库。我从两个表中获取数据并在ListView中显示它。我想实现事件监听器或Observer模式,这样我就可以在数据库中发生更改(插入,删除或更新)时刷新UI。

How can I achieve it? Does GreenDao provide any such thing?

我怎样才能实现它? GreenDao提供这样的东西吗?

1 个解决方案

#1


0  

You can use an existing event bus implementation such as Otto

您可以使用现有的事件总线实现,例如Otto

With it it's just a matter of adding some annotations to the class in which you want to observe events.

有了它,只需要在您想要观察事件的类中添加一些注释。

#1


0  

You can use an existing event bus implementation such as Otto

您可以使用现有的事件总线实现,例如Otto

With it it's just a matter of adding some annotations to the class in which you want to observe events.

有了它,只需要在您想要观察事件的类中添加一些注释。