Skip to content

Commit

Permalink
refactor: use the MapKey symbol from utils 🥳
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakkulkarni committed Apr 13, 2022
1 parent f3d9146 commit 57ca82d
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 27 deletions.
3 changes: 1 addition & 2 deletions src/controls/VControlAttribution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import { AttributionControl } from 'mapbox-gl';
import type { PropType } from 'vue';
import { defineComponent, onMounted } from 'vue';
import { MapKey } from '../../types/symbols';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VControlAttribution',
Expand Down
3 changes: 1 addition & 2 deletions src/controls/VControlFullscreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import { FullscreenControl } from 'mapbox-gl';
import type { PropType } from 'vue';
import { defineComponent, onMounted } from 'vue';
import { MapKey } from '../../types/symbols';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VControlFullscreen',
Expand Down
3 changes: 1 addition & 2 deletions src/controls/VControlGeolocate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import { GeolocateControl } from 'mapbox-gl';
import type { PropType } from 'vue';
import { defineComponent, onMounted } from 'vue';
import { MapKey } from '../../types/symbols';
import { geolocateControlEvents as events } from '../constants/events/geolocate';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VControlFullscreen',
Expand Down
3 changes: 1 addition & 2 deletions src/controls/VControlNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { NavigationControl } from 'mapbox-gl';
import type { PropType } from 'vue';
import { defineComponent, onMounted } from 'vue';
import { MapKey } from '../../types/symbols';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VControlFullscreen',
Expand Down
3 changes: 1 addition & 2 deletions src/controls/VControlScale.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { ScaleControl } from 'mapbox-gl';
import type { PropType } from 'vue';
import { defineComponent, onMounted } from 'vue';
import { MapKey } from '../../types/symbols';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VControlFullscreen',
Expand Down
3 changes: 1 addition & 2 deletions src/layers/mapbox/VLayerMapboxCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import type { AnyLayer, GeoJSONSourceRaw } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import { MapKey } from '../../../types/symbols';
import { injectStrict } from '../../utils';
import { injectStrict, MapKey } from '../../utils';
export default defineComponent({
name: 'VLayerMapboxCanvas',
Expand Down
3 changes: 1 addition & 2 deletions src/layers/mapbox/VLayerMapboxGeojson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import type { AnyLayer, GeoJSONSourceRaw } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import { MapKey } from '../../../types/symbols';
import { injectStrict } from '../../utils';
import { injectStrict, MapKey } from '../../utils';
export default defineComponent({
name: 'VLayerMapboxGeojson',
Expand Down
3 changes: 1 addition & 2 deletions src/layers/mapbox/VLayerMapboxImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import type { AnyLayer, ImageSourceRaw } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import { MapKey } from '../../../types/symbols';
import { injectStrict } from '../../utils';
import { injectStrict, MapKey } from '../../utils';
export default defineComponent({
name: 'VLayerMapboxImage',
Expand Down
3 changes: 1 addition & 2 deletions src/layers/mapbox/VLayerMapboxRaster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import type { AnyLayer, GeoJSONSourceRaw } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import { MapKey } from '../../../types/symbols';
import { injectStrict } from '../../utils';
import { injectStrict, MapKey } from '../../utils';
export default defineComponent({
name: 'VLayerMapboxRaster',
Expand Down
3 changes: 1 addition & 2 deletions src/layers/mapbox/VLayerMapboxVector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import type { AnyLayer, VectorSource } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import { MapKey } from '../../../types/symbols';
import { injectStrict } from '../../utils';
import { injectStrict, MapKey } from '../../utils';
export default defineComponent({
name: 'VLayerMapboxVector',
Expand Down
3 changes: 1 addition & 2 deletions src/layers/mapbox/VLayerMapboxVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import type { AnyLayer, VectorSource } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import { MapKey } from '../../../types/symbols';
import { injectStrict } from '../../utils';
import { injectStrict, MapKey } from '../../utils';
export default defineComponent({
name: 'VLayerMapboxVideo',
Expand Down
2 changes: 1 addition & 1 deletion src/map/VMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { Map } from 'mapbox-gl';
import type { PropType, Ref, SetupContext } from 'vue';
import { defineComponent, onMounted, provide, ref } from 'vue';
import { MapKey } from '../../types/symbols';
import { mapEvents } from '../constants/events';
import { MapKey } from '../utils';
export default defineComponent({
name: 'VMap',
Expand Down
3 changes: 1 addition & 2 deletions src/markers/VMarker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import { Marker } from 'mapbox-gl';
import type { PropType, Ref, SetupContext } from 'vue';
import { defineComponent, onMounted, ref } from 'vue';
import { MapKey } from '../../types/symbols';
import { markerDOMEvents, markerMapEvents } from '../constants/events';
import VPopup from '../popups/VPopup.vue';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VMarker',
Expand Down
3 changes: 1 addition & 2 deletions src/popups/VPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { Popup } from 'mapbox-gl';
import type { PropType, Ref, SetupContext } from 'vue';
import { defineComponent, onBeforeUnmount, onMounted, ref } from 'vue';
import { MapKey } from '../../types/symbols';
import { popupEvents } from '../constants/events';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VPopup',
Expand Down
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export function injectStrict<T>(key: InjectionKey<T>, fallback?: T): T {
}
return resolved;
}

export { MapKey } from './symbols';
6 changes: 6 additions & 0 deletions src/utils/symbols.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Map } from 'mapbox-gl';
import type { InjectionKey, Ref } from 'vue';

const MapKey: InjectionKey<Ref<Map>> = Symbol('Map');

export { MapKey };

0 comments on commit 57ca82d

Please sign in to comment.