diegoazh / gmap-vue

A wrapper component for consuming Google Maps API built on top of Vue. Fork of the popular vue-google-maps plugin.
https://diegoazh.github.io/gmap-vue/
173 stars 51 forks source link

Remove exposed instances because they are always `undefined` #319

Closed diegoazh closed 6 months ago

diegoazh commented 6 months ago

Writing component tests I discovered that all exposed instances, I mean mapInstance, markerInstance, etc, are always undefined.

This happens because the instance variable is undefined in the setup phase and it's only populated on the mounted hook.

To get the assigned instance later we need to use a computed to reevaluate which is the content of the variable when you call it. This looks redundant for the following reasons.

We exposed a promise in all components (in the next fix we'll add it to autocomplete too) and it returns undefined if the Google component is not created, or the created instance. Also, a computed will be exposed and it will return undefined if the Google component is not created or the created instance. For these reasons, we think a better option could be to remove the exposed instance and only expose the promise that resolves it.

diegoazh commented 6 months ago

Finally, we decided to remove all exposed instances and maintain the promises that resolved them.