Refactoring: Move data loading code under the datasource directory

This commit is contained in:
Przemek Wiech
2020-05-12 21:46:30 +02:00
parent 3eb48ce665
commit 6ef4dbc858
4 changed files with 174 additions and 155 deletions

View File

@@ -0,0 +1,30 @@
import {IndiInfo} from 'topola';
import {TopolaData} from '../util/gedcom_util';
/** Supported data sources. */
export enum DataSourceEnum {
UPLOADED,
GEDCOM_URL,
WIKITREE,
}
/** Source specification together with individual selection. */
export interface SourceSelection<SourceSpecT> {
spec: SourceSpecT;
selection?: IndiInfo;
}
/** Interface encapsulating functions specific for a data source. */
export interface DataSource<SourceSpecT> {
/**
* Returns true if the application is now loading a completely new data set
* and the existing one should be wiped.
*/
isNewData(
newSource: SourceSelection<SourceSpecT>,
oldSource: SourceSelection<SourceSpecT>,
data?: TopolaData,
): boolean;
/** Loads data from the data source. */
loadData(spec: SourceSelection<SourceSpecT>): Promise<TopolaData>;
}