objectbox / objectbox/objectbox-dart

store.watch<Entity> - return changes instead of void

Open
#455 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

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 ;-)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the store.watch entry point and compare its behavior with objectBox.store.entityChanges, both mentioned in the issue. Determine the intended entity payload and API implications; done means a watch stream provides the changed entity in a way that supports synchronization without switching across entity types.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.