terriajs
Version:
Geospatial data visualization platform.
33 lines (27 loc) • 876 B
text/typescript
import { action, observable } from "mobx";
import { fromPromise } from "mobx-utils";
import SearchProviderResults from "./SearchProviderResults";
export default abstract class SearchProvider {
/** If search results are References to models in terria.models - set this to true.
* This is so groups/references are opened and loaded properly
*/
readonly resultsAreReferences: boolean = false;
name = "Unknown";
isOpen = true;
toggleOpen() {
this.isOpen = !this.isOpen;
}
search(searchText: string): SearchProviderResults {
const result = new SearchProviderResults(this);
result.resultsCompletePromise = fromPromise(
this.doSearch(searchText, result)
);
return result;
}
protected abstract doSearch(
searchText: string,
results: SearchProviderResults
): Promise<void>;
}