objectbox-java
objectbox-java copied to clipboard
Support observing multiple boxes
Maybe support an store.boxFor(Class[]).query()?
You can use one of the BoxStore.subscribe() methods to achieve that. Does that work for you?
Does the method only triggers one time after an transaction with multiple types involved?
No, it invokes per Class passing the Class as an parameter.
Ok, what would be the best practice to get all objects from 3 boxes?
@FabianTerhorst Getting all objects (box.getAll()) or getting notifications? The latter would involve BoxStore.subscribe() and check the class in the callback. The callback is called 3 times for three boxes. If you want just a single call being made, we may consider an additional method to be implemented. In that case it would help to see the use case. If that may be useful for other users, we will consider it.
@greenrobot i have a list of objects inside an recyclerview, the list is containing 3 different types of objects.
Thinking about changing the callback to receive a list of changed entity classes...
If you have an entity with a list of other entities, shouldnt the other entities changing also trigger the parents change?
E.g.:
-
ExerciseEntity
has a list ofBodypartEntity
- A
BodypartEntity
changes -
BodypartEntity
gets notified, but notExerciseEntity
I understand that this makes it far more complex, but a hint on whether you are planning to incorporate it or not would be great!