Support observing individual objects
Note these related feature requests:
- #1027
- #268
while one can easily listen to changes to lists (queries), there is no way to listen to changes of some particular object
That would be a feature request.
To better understand your use case: how many objects do you want to observe? Are you interested to observe object deletions?
typical use case is following:
- there is a list of objects (models) I'd like to show on screen
- list is presented by ListViewModel which exposes some kind of ObserableList <ItemViewModel> Items
- each ItemViewModel wraps over model object from DAL
- ItemViewModel exposes some kind of Observable interface to a view
- ideally ItemViewModel should be able to subscribe to changes in model and translate those changes into changes of ItemViewModel
I would estimate that at the same time there could be up to 100 objects being observed. deletions in my use case are handled in ListViewModel which subscribes to changes in query
So the source of initial list (entities) is not a query?
quite often it is, but I'd like to decouple ListVM and ItemVM and avoid listening to object changes via query listener
@avestnik One advantage of list-based observers is that they cover removals and inserts. Wouldn't you still need those? If you do, does it make sense to also observe on the object level?
I need both, ListVM listens to inserts/deletions, ItemVM listens to object changes
This would be nice to have, but also still doable in the current iteration. I also need to listen to both list and single object changes. For the single object changes I just do a query on the object id and wrap the DataSubscription with an Observable to emmit the only item in the list passed in the DataSubscription.observer.