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
2ndly: I'm trying to figure out how to get the first result (i.e. the first complete aggregate) from a liveFind() call.
It looks i call liveFind(query) then each doc will be returned as an update event with an ADD action, which we have to debounce (new concept to me, thanks 🙂). E.g.
In lots of my use-cases we show a spinner and have a few queries to await, then we populate the UI. It would be nice if the first result was passed in the liveFind promise resolution, e.g.
async myfunc() {
let liveFeed = db.liveFind(query1)
.on('update', (update, query1Aggregate) => {
debouncedRefreshUI(query1Aggregate)
})
let query1Result = await liveFeed
// Do some other async stuff we need for the UI
let query2Result = await db.find(query2)
let query3Result = await db.find(query3)
// Populate the UI
refreshUI(query1Result.docs, query2Result.docs, query3Result.docs)
}
My head is hurting imagining how to mix normal and debounced results without a first-result list!
EDIT:
I see liveFind() returns an EventEmitter with added then and catch that are bound to the pouchdb.find() promise under the hood. Not sure if you can await an object like that, hmm. EDIT:
Just did a quick test – both... let result = await db.liveFind(query)
and db.liveFind(query).then( result => { } )
always give result as undefined.
In the same setup db.find(query) gives a proper result. I'm wondering if this is expected behaviour for liveFind?
The text was updated successfully, but these errors were encountered:
Hi. Firstly thanks for this great little plugin!
2ndly: I'm trying to figure out how to get the first result (i.e. the first complete aggregate) from a liveFind() call.
It looks i call
liveFind(query)
then each doc will be returned as anupdate
event with an ADD action, which we have to debounce (new concept to me, thanks 🙂). E.g.In lots of my use-cases we show a spinner and have a few queries to await, then we populate the UI. It would be nice if the first result was passed in the liveFind promise resolution, e.g.
My head is hurting imagining how to mix normal and debounced results without a first-result list!
EDIT:
I see liveFind() returns an
EventEmitter
with addedthen
andcatch
that are bound to thepouchdb.find()
promise under the hood. Not sure if you canawait
an object like that, hmm.EDIT:
Just did a quick test – both...
let result = await db.liveFind(query)
and
db.liveFind(query).then( result => { } )
always give result as
undefined
.In the same setup
db.find(query)
gives a proper result. I'm wondering if this is expected behaviour forliveFind
?The text was updated successfully, but these errors were encountered: