Rename onProgress callback

This commit is contained in:
Jos de Jong 2020-09-23 08:18:32 +02:00
parent fd673a4ea0
commit 6fb6bc68e6
2 changed files with 6 additions and 6 deletions

View File

@ -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)

View File

@ -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, [])