Skip to content

Commit

Permalink
feat: add emits as per Vue 3 docs 📖
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
  • Loading branch information
vinayakkulkarni committed Mar 9, 2023
1 parent f12ef0a commit 5c873f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/map/VMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}),
},
},
emits: ['loaded', ...mapEvents],
setup(props, { emit }) {
let map: Ref<Map> = shallowRef({} as Map);
let loaded: Ref<boolean> = ref(false);
Expand Down
11 changes: 9 additions & 2 deletions src/markers/VMarker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script lang="ts">
import type { LngLatLike, MarkerOptions, PopupOptions } from 'maplibre-gl';
import { Marker } from 'maplibre-gl';
import type { PropType, Ref, SetupContext } from 'vue';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref } from 'vue';
import { markerDOMEvents, markerMapEvents } from '../constants/events';
import VPopup from '../popups/VPopup.vue';
Expand Down Expand Up @@ -46,7 +46,14 @@
required: false,
},
},
setup(props, { emit }: SetupContext) {
emits: [
'added',
'update:coordinates',
'removed',
...markerMapEvents,
...markerDOMEvents,
],
setup(props, { emit }) {
let map = injectStrict(MapKey);
let marker: Marker = new Marker(props.options);
let loaded: Ref<boolean> = ref(true);
Expand Down
5 changes: 3 additions & 2 deletions src/popups/VPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script lang="ts">
import type { LngLatLike, Map, Marker, PopupOptions } from 'maplibre-gl';
import { Popup } from 'maplibre-gl';
import type { PropType, Ref, SetupContext } from 'vue';
import type { PropType, Ref } from 'vue';
import { defineComponent, onBeforeUnmount, onMounted, ref } from 'vue';
import { popupEvents } from '../constants/events';
import { MapKey } from '../utils/symbols';
Expand All @@ -31,7 +31,8 @@
required: true,
},
},
setup(props, { emit }: SetupContext) {
emits: ['added', 'removed', ...popupEvents],
setup(props, { emit }) {
let map: Ref<Map> = injectStrict(MapKey);
let popup: Popup = new Popup(props.options);
let loaded: Ref<boolean> = ref(true);
Expand Down

0 comments on commit 5c873f1

Please sign in to comment.