Closed fireflysemantics closed 2 years ago
I'm trying to create a lunr index and use it immediately. Another one of the issues showed how to use promises to do this, but IIUC this is also broken because the promise resolves the index before it is initialized:
function createLunrIndex(todos: Todo[], fieldNames: string[]) { return new Promise((resolve, reject) => { const idx = lunr(function () { fieldNames.forEach((fn) => { this.field(fn); }); todos.forEach((todo) => { this.add(todo); }); }); resolve(idx); }); }
https://github.com/olivernn/lunr.js/issues/497
This is a stackblitz demo: https://stackblitz.com/edit/firefly-semantics-slice-entity-guide-fuodgg
Is there a way to wait for the initialization of the index?
Also asked about this on SO: https://stackoverflow.com/questions/72116666/waiting-for-the-lunr-index-to-initialize
Ooops I think I searched for the wrong thing. Closing for now ...
I'm trying to create a lunr index and use it immediately. Another one of the issues showed how to use promises to do this, but IIUC this is also broken because the promise resolves the index before it is initialized:
https://github.com/olivernn/lunr.js/issues/497
This is a stackblitz demo: https://stackblitz.com/edit/firefly-semantics-slice-entity-guide-fuodgg
Is there a way to wait for the initialization of the index?
Also asked about this on SO: https://stackoverflow.com/questions/72116666/waiting-for-the-lunr-index-to-initialize