objectbox / objectbox/objectbox-java
Only re-deliver query results if results have changed
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 4.6k
- Fork
- 311
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Code example probably will be best description here.
@Entity
class KAEntry(
@Unique val key: String,
val value: String,
@Id var id: Long = 0
)
class MyApp : Application() {
private lateinit var subs1: DataSubscription
private lateinit var subs2: DataSubscription
private lateinit var boxStore: BoxStore
private set
override fun onCreate() {
super.onCreate()
boxStore = MyObjectBox.builder().name("main").androidContext(this).build()
val box = boxStore.boxFor(KAEntry::class.java)
box.removeAll() // just for reproducibility, to avoid "unique constraint violation" on second run of app
subs1 = box.query().equal(KAEntry_.key, "key1")
.build().subscribe().observer { v ->
Log.i("MyApp", "triggered for key1" )
}
subs2 = box.query().equal(KAEntry_.key, "key2")
.build().subscribe().observer { v ->
Log.i("MyApp", "triggered for key2" )
}
box.put(KAEntry("key1","some value"))
}
}
Problem is that even I've only put "key1" object and therefore only first query should trigger it's observer - both actually get triggered:
2021-04-05 14:22:53.263 25926-25962/com.acme I/MyApp: triggered for key1
2021-04-05 14:22:53.263 25926-25963/com.acme I/MyApp: triggered for key2
Either I don't understand something or this observer on query actually bugged.
I can see that triggering observer for only those objects that are changed and are in query result may have some performance impact. Though even in this case I would like to have some way of detecting that change was made to objects that query returns and not any object of this type.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non viene indicato alcun file sorgente, test o punto di ingresso. Inizia riproducendo l’esempio Kotlin di sottoscrizione a una query, quindi segui l’implementazione del query observer e i relativi test, se presenti. Il lavoro è completato quando gli observer ricevono notifiche solo se cambiano i risultati delle loro query, oppure quando viene documentato il modo supportato per rilevare le modifiche rilevanti agli oggetti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- kotlin
- Ambito
- databases, mobile-dev
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100