You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to hook up a custom REST synchronization service to entity changes and have something like this to listen to model changes:
final objectBox = await ObjectBox.create();
...
final stream = objectBox.store.watch<FormAnswer>();
stream.listen((event) {
print('answers changed');
// sync the changed model with server
});
Describe the solution you'd like
I actually would expect the stream to return the entity that changed. Returning a Stream with void does not make too much sense in my opinion. You get informed that 'something' changed, without knowing what...
I've seen there is also the option to subscribe to objectBox.store.entityChanges which kinda does, what I want. It's just not as convenient as the first one, since you'd have to switch through all Entity types first, to handle them accordingly.
Just an idea for a future version ;-)
The text was updated successfully, but these errors were encountered:
Thanks! As an alternative you could update a timestamp in FormAnswer and then run a query to get objects with a timestamp greater than last checked whenever the Box has changes (or watch that query directly).
This is related to the feature request #203 for our Java library.
greenrobot-team
changed the title
store.watch<Entity> - return entity instead of void
store.watch<Entity> - return changes instead of void
Aug 16, 2022
Thanks for the suggestion, yes, that's pretty much what I implemented in the meanwhile: Listening to a query on an "SyncStatus"-enum...
Working well so far and looking forward when in some future version, dart model inheritance will be implemented. I've seen there is already an issue for that :)
I try to hook up a custom REST synchronization service to entity changes and have something like this to listen to model changes:
Describe the solution you'd like
I actually would expect the stream to return the entity that changed. Returning a Stream with void does not make too much sense in my opinion. You get informed that 'something' changed, without knowing what...
I've seen there is also the option to subscribe to
objectBox.store.entityChanges
which kinda does, what I want. It's just not as convenient as the first one, since you'd have to switch through all Entity types first, to handle them accordingly.Just an idea for a future version ;-)
The text was updated successfully, but these errors were encountered: