Skip to content

Commit

Permalink
pass constructor to sourceREgistry instead of factory
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 30, 2020
1 parent 819003a commit ea74cc0
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ const previewGeojsonFile = (onPreviewSource, inspectorAdapters) => {
};

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new GeojsonFileSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: GeojsonFileSource,
type: GEOJSON_FILE,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ export class EMSFileSource extends AbstractVectorSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new EMSFileSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: EMSFileSource,
type: EMS_FILE,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ export class EMSTMSSource extends AbstractTMSSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new EMSTMSSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: EMSTMSSource,
type: EMS_TMS,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@ export class ESGeoGridSource extends AbstractESAggSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new ESGeoGridSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: ESGeoGridSource,
type: ES_GEO_GRID,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ export class ESPewPewSource extends AbstractESAggSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new ESPewPewSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: ESPewPewSource,
type: ES_PEW_PEW,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,7 @@ export class ESSearchSource extends AbstractESSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new ESSearchSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: ESSearchSource,
type: ES_SEARCH,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ export class KibanaRegionmapSource extends AbstractVectorSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new KibanaRegionmapSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: KibanaRegionmapSource,
type: REGIONMAP_FILE,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ export class KibanaTilemapSource extends AbstractTMSSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new KibanaTilemapSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: KibanaTilemapSource,
type: KIBANA_TILEMAP,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { AbstractSourceDescriptor } from '../../../common/descriptor_types';
import { ISource } from './source';

type SourceRegistryEntry = {
factory: (sourceDescriptor: AbstractSourceDescriptor, inspectorAdapters: object) => ISource;
ConstructorFunction: new (
sourceDescriptor: AbstractSourceDescriptor,
inspectorAdapters: unknown
) => ISource;
type: string;
};

Expand All @@ -26,10 +29,10 @@ function getSourceByType(sourceType: string): SourceRegistryEntry | undefined {
export function createSourceInstance(
sourceDescriptor: AbstractSourceDescriptor,
inspectorAdapters: object
) {
): ISource {
const source = getSourceByType(sourceDescriptor.type);
if (!source) {
throw new Error(`Unrecognized sourceType ${sourceDescriptor.type}`);
}
return source.factory(sourceDescriptor, inspectorAdapters);
return new source.ConstructorFunction(sourceDescriptor, inspectorAdapters);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ export class WMSSource extends AbstractTMSSource {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new WMSSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: WMSSource,
type: WMS,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ class XYZTMSEditor extends React.Component {
}

registerSource({
factory: (sourceDescriptor, inspectorAdapters) => {
return new XYZTMSSource(sourceDescriptor, inspectorAdapters);
},
ConstructorFunction: XYZTMSSource,
type: EMS_XYZ,
});

Expand Down

0 comments on commit ea74cc0

Please sign in to comment.