Rename onProgress callback
This commit is contained in:
parent
fd673a4ea0
commit
6fb6bc68e6
|
@ -135,7 +135,7 @@ async function tick () {
|
|||
}
|
||||
|
||||
// TODO: comment
|
||||
export function searchAsync (searchText, doc, { onPartlyResults, onDone }) {
|
||||
export function searchAsync (searchText, doc, { onProgress, onDone }) {
|
||||
const yieldAfterItemCount = 10000 // TODO: what is a good value?
|
||||
const search = searchGenerator(searchText, doc, yieldAfterItemCount)
|
||||
|
||||
|
@ -150,7 +150,7 @@ export function searchAsync (searchText, doc, { onPartlyResults, onDone }) {
|
|||
next = search.next()
|
||||
if (next.value) {
|
||||
results.push(next.value) // TODO: make this immutable?
|
||||
onPartlyResults(results)
|
||||
onProgress(results)
|
||||
}
|
||||
await tick() // TODO: be able to wait longer than just one tick? So the UI stays fully responsive?
|
||||
} while (!cancelled && !next.done)
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('search', () => {
|
|||
|
||||
const callbacks = []
|
||||
|
||||
function onPartlyResults (results) {
|
||||
function onProgress (results) {
|
||||
callbacks.push(results.slice(0))
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ describe('search', () => {
|
|||
done()
|
||||
}
|
||||
|
||||
searchAsync('4', doc, { onPartlyResults, onDone })
|
||||
searchAsync('4', doc, { onProgress, onDone })
|
||||
|
||||
// should not have results right after creation, but only on the first next tick
|
||||
assert.deepStrictEqual(callbacks, [])
|
||||
|
@ -73,7 +73,7 @@ describe('search', () => {
|
|||
|
||||
const callbacks = []
|
||||
|
||||
function onPartlyResults (results) {
|
||||
function onProgress (results) {
|
||||
callbacks.push(results.slice(0))
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ describe('search', () => {
|
|||
throw new Error('onDone should not be invoked')
|
||||
}
|
||||
|
||||
const { cancel } = searchAsync('4', doc, { onPartlyResults, onDone })
|
||||
const { cancel } = searchAsync('4', doc, { onProgress, onDone })
|
||||
|
||||
// should not have results right after creation, but only on the first next tick
|
||||
assert.deepStrictEqual(callbacks, [])
|
||||
|
|
Loading…
Reference in New Issue