isIndexing as a svelte store

This commit is contained in:
Simon Cambier
2022-10-27 19:30:52 +02:00
parent 22ff4eec03
commit 573f3fa31b
2 changed files with 5 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ import {
import type { Query } from './query'
import { settings } from '../settings'
import { cacheManager } from '../cache-manager'
import { writable } from 'svelte/store'
const tokenize = (text: string): string[] => {
const tokens = text.split(SPACE_OR_PUNCTUATION)
@@ -49,7 +50,7 @@ export const minisearchOptions: Options<IndexedDocument> = {
export class SearchEngine {
private static engine: SearchEngine
private static tmpEngine: SearchEngine
public static isIndexing = true
public static isIndexing = writable(true)
/**
* The main singleton SearchEngine instance.
@@ -93,7 +94,7 @@ export class SearchEngine {
*/
public static swapEngines(): void {
;[this.engine, this.tmpEngine] = [this.tmpEngine, this.engine]
this.isIndexing = false
this.isIndexing.set(false)
}
private minisearch: MiniSearch