Skip to content

Commit 9f5a986

Browse files
committed
fix: fix for circular reference (this time working)
1 parent 546852b commit 9f5a986

32 files changed

+69
-59
lines changed

src/BaseNative.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Observable } from '@nativescript/core/data/observable';
2+
3+
export abstract class BaseNative<T, U extends {}> extends Observable {
4+
constructor(public options: U = {} as any, native?: T) {
5+
super();
6+
if (native) {
7+
this.native = native;
8+
}
9+
}
10+
native: T;
11+
protected duringInit = false;
12+
initNativeView(native: T, options: U) {
13+
this.duringInit = true;
14+
for (const key in options) {
15+
(this as any)[key] = options[key];
16+
}
17+
this.duringInit = false;
18+
}
19+
getNative() {
20+
if (!this.native) {
21+
this.native = this.createNative(this.options);
22+
this.initNativeView(this.native, this.options);
23+
}
24+
return this.native;
25+
}
26+
abstract createNative(options: U): T;
27+
}

src/core/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseNative } from '../index.common';
1+
import { BaseNative } from '../BaseNative';
22
import { AltitudeKey, DefaultLatLonKeys, GenericMapPos, LatitudeKey, LongitudeKey, MapPos, MapVec, ScreenBounds, ScreenPos, setMapPosKeys } from './index.common';
33
export { LatitudeKey, LongitudeKey, MapPos, ScreenBounds, ScreenPos, setMapPosKeys };
44

src/core/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseNative } from '../index.common';
1+
import { BaseNative } from "../BaseNative";
22
import { AltitudeKey, DefaultLatLonKeys, GenericMapPos, LatitudeKey, LongitudeKey, MapPos, MapVec, ScreenBounds, ScreenPos, setMapPosKeys } from './index.common';
33
export { LatitudeKey, LongitudeKey, MapPos, ScreenBounds, ScreenPos, setMapPosKeys };
44

src/datasources/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CombinedTileDataSourceOptions, DataSourceOptions, GeoJSONVectorTileDataSourceOptions, MergedMBVTTileDataSourceOptions, OrderedTileDataSourceOptions, TileDataSourceOptions } from '.';
22
import { featureCollectionFromArgs, nativeProperty } from '..';
33
import { FeatureCollection } from '../geometry/feature';
4-
import { BaseNative } from '../index.common';
4+
import { BaseNative } from "../BaseNative";
55
import { Projection } from '../projections';
66
import { JSVariantToNative, jsonVariant } from '../utils';
77

src/datasources/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CombinedTileDataSourceOptions, DataSourceOptions, GeoJSONVectorTileDataSourceOptions, MergedMBVTTileDataSourceOptions, OrderedTileDataSourceOptions, TileDataSourceOptions } from '.';
22
import { featureCollectionFromArgs, nativeProperty } from '..';
33
import { FeatureCollection } from '../geometry/feature.ios';
4-
import { BaseNative } from '../index.common';
4+
import { BaseNative } from "../BaseNative";
55
import { Projection } from '../projections';
66
import { JSVariantToNative, jsonVariant } from '../utils';
77

src/geocoding/service.common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseNative } from '../index.common';
1+
import { BaseNative } from '../BaseNative';
22
import { GeocodingServiceOptions } from './service';
33

44
export abstract class BaseGeocodingService<T, U extends GeocodingServiceOptions> extends BaseNative<T, U> {}

src/geometry/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GeometryOptions, LineGeometryOptions, PointGeometryOptions, PolygonGeometryOptions } from '.';
22
import { mapPosVectorFromArgs } from '..';
33
import { MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core';
4-
import { BaseNative } from '../index.common';
4+
import { BaseNative } from "../BaseNative";
55

66
export abstract class Geometry<T extends com.carto.geometry.Geometry, U extends GeometryOptions> extends BaseNative<T, U> {
77
getCenterPos() {

src/geometry/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DefaultLatLonKeys, GenericMapPos, MapBounds, MapPos, MapPosVector } from '../core';
2-
import { BaseNative } from '../index.common';
2+
import { BaseNative } from "../BaseNative";
33

44
export interface GeometryOptions<T = DefaultLatLonKeys> {}
55
export abstract class Geometry<T = DefaultLatLonKeys, U extends GeometryOptions = GeometryOptions<T>> extends BaseNative<any, U> {

src/geometry/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GeometryOptions, LineGeometryOptions, PointGeometryOptions, PolygonGeometryOptions } from '.';
22
import { mapPosVectorFromArgs } from '..';
33
import { MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core';
4-
import { BaseNative } from '../index.common';
4+
import { BaseNative } from "../BaseNative";
55

66
export abstract class Geometry<T extends NTGeometry, U extends GeometryOptions> extends BaseNative<T, U> {
77
getCenterPos() {

src/geometry/reader.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseNative } from '../index.common';
1+
import { BaseNative } from "../BaseNative";
22
import { GeoJSONGeometryReaderOptions, WKBGeometryReaderOptions, WKTGeometryReaderOptions } from './reader';
33
import { FeatureCollection } from './feature';
44
import { Projection } from '../projections';

0 commit comments

Comments
 (0)