Improve DataObserver reference holding
See original GitHub issueI’m trying to use obervable queries to detect when the user is logged in my application in order to start fetching data in background with correct authorization token.
...
userBox.query().build().subscribe().observe(users -> fetchUserData());
...
boxStore.subscribe(User.class).observe(class -> fetchUserData());
First “live” query doesn’t work whilst the second works fine whenever I put(user)
a new user in the userBox
.
Is this correct? I’m not sure from which thread the user is being inserted, might this be an issue? Does it make sense to use a “live” query to observe the insertion of new objects or is it just for changes in existing objects? Live queries would be great, for my application and are the main feature that made me pick ObjectBox, hope I can get it working.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Observers - Reference - Backtrader
This observer stores the returns of the strategy and the return of a reference asset which is one of the datas passed to...
Read more >What type of reference does NSNotificationCenter keep for ...
I believe a weak reference, though that's just from memory (no pun intended). what are the best practices for removing observers from the...
Read more >LiveData overview - Android Developers
Create an instance of LiveData to hold a certain type of data. This is usually done within your ViewModel class. Create an Observer...
Read more >ESTIMATING OBSERVER AND DATA REPUTATION IN ... - IHR
Figure 9: Pre-correction observation and reference data depth (top; note depth is positive down in this view, so vertical axis is increasing ......
Read more >The Observer Pattern and Creational Methods - RxJS inDepth
RxJS improves upon this classical observer pattern by introducing a more robust ... so nothing has been emitted yet. obs just holds a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks! Keeping the reference works, though it’s kind of a drag.
The only difference to subscribing using
boxStore
directly is a call to.weak()
and.onlyChanges()
when the subscription is built. As the second doesn’t matter when subscribing to a query (the initial value is always published) I assume it has to be the weak reference.@Onheiron Can you try keeping a reference to the Query (result of
build()
) or DataSubscription (result ofobserver()
) instance, for example in a field? -ut