My use case is the geocoder.geocode
api from the google map library. I'm using it to convert a given user address to a latitude/longitude coordinate for use with another google map api.
This api executes the callback when it is finished searching the input address. From within the callback, I am trying to access a member of my class by using the this
keyword.
I understand this
, from within a closure refers to a different context than the class the closure sits in - so at the top of the method I've created variable and cached off the this
instance, by doing var self = this
.
This works, but is it the accepted approach? I am using ES6 if that matters.