rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.22k stars 838 forks source link

Should setAccessToken return a Promise #2005

Closed YousefED closed 1 year ago

YousefED commented 2 years ago

For this library to work well, the consumer is expected to call setAccessToken to initialize it (even when not using Mapbox, no call to setAccessToken breaks).

The current implementation (java: https://github.com/rnmapbox/maps/blob/98c8f50a18c7b4f0b1ff0ee1606e4cc53b63a888/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/modules/RCTMGLModule.java#L302) returns before the new accesstoken is applied. This can cause issues since for example calling "getPacks" immediately after setAccessToken could fail.

A solution might be to make setAccessToken only resolve after it has been applied.

mfazekas commented 2 years ago

@YousefED I think it's a good idea