Skip to content

Commit 7dc8df6

Browse files
HeyStensonSnailBonesrreusser
authored
Note that prewarm() is synchronous (#10998)
* note that prewarm is synchronous * Applying suggestions so we can get this into v2.5 Co-authored-by: Aidan H <[email protected]> Co-authored-by: Ricky Reusser <[email protected]>
1 parent 1940dbc commit 7dc8df6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@ const exported = {
5757
* used, must be set before `prewarm()` is called to have an effect.
5858
*
5959
* By default, the lifecycle of these resources is managed automatically, and they are
60-
* lazily initialized when a Map is first created. By invoking `prewarm()`, these
61-
* resources will be created ahead of time, and will not be cleared when the last Map
62-
* is removed from the page. This allows them to be re-used by new Map instances that
60+
* lazily initialized when a `Map` is first created. Invoking `prewarm()` creates these
61+
* resources ahead of time and ensures they are not cleared when the last `Map`
62+
* is removed from the page. This allows them to be re-used by new `Map` instances that
6363
* are created later. They can be manually cleared by calling
64-
* `mapboxgl.clearPrewarmedResources()`. This is only necessary if your web page remains
65-
* active but stops using maps altogether.
64+
* `mapboxgl.clearPrewarmedResources()`. This is only necessary if your web page
65+
* remains active but stops using maps altogether. `prewarm()` is idempotent
66+
* and has guards against being executed multiple times, and any resources
67+
* allocated by `prewarm()` are created synchronously.
6668
*
67-
* This is primarily useful when using Mapbox GL JS maps in a single page app, in which a user
68-
* would navigate between various views that can cause Map instances to constantly be
69-
* created and destroyed.
69+
* This is primarily useful when using Mapbox GL JS maps in a single page app,
70+
* in which a user navigates between various views, resulting in
71+
* constant creation and destruction of `Map` instances.
7072
*
7173
* @function prewarm
7274
* @example

0 commit comments

Comments
 (0)