Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add invalidateAmbientCache method #899

Merged
merged 1 commit into from
Jun 9, 2020

Conversation

tsemerad
Copy link
Contributor

@tsemerad tsemerad commented Jun 1, 2020

This adds the invalidateAmbientCache method that is available in both the iOS and Android SDKs. Tested and working as expected in my app.

As a side note, I couldn't get npm run generate to work. It keeps failing on generating the docs, with the following error:

UnhandledPromiseRejectionWarning: Browserslist: caniuse-lite is outdated. Please run next command `npm update`

It appears to be failing on the npx documentation build ${MODULES_PATH} -f json command. I tried using different versions of documentation without any success. So I added the docs change by hand for now.

@mfazekas
Copy link
Contributor

mfazekas commented Jun 2, 2020

@tsemerad thanks much for the contribution i'll try to look into the doc generation issue.

@mfazekas
Copy link
Contributor

mfazekas commented Jun 2, 2020

@tsemerad also it would be great if you could wire in to some of the examples, so it's easier to test the change

@mfazekas
Copy link
Contributor

mfazekas commented Jun 2, 2020

@tsemerad i could not repro your issue with doc generation:

git clone https://github.com/alseageo/maps
cd maps/
git checkout invalidateAmbientCache
npm run generate

git diff
diff --git a/docs/OfflineManager.md b/docs/OfflineManager.md
index 821f0e7..b49307e 100644
--- a/docs/OfflineManager.md
+++ b/docs/OfflineManager.md
@@ -46,6 +46,7 @@ Unregisters the given offline pack and allows resources that are no longer requi
 await MapboxGL.offlineManager.deletePack('packName')
 ```
 
+
 #### invalidateAmbientCache()
 
 Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.<br/>This is the recommend method for clearing the cache.<br/>This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.<br/>It does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects.
diff --git a/docs/docs.json b/docs/docs.json
index 428e3d2..9f3b6fd 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -5573,6 +5573,20 @@
           }
         }
       },
+      {
+        "name": "invalidateAmbientCache",
+        "description": "Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.\nThis is the recommend method for clearing the cache.\nThis is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.\nIt does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects.",
+        "params": [],
+        "examples": [
+          "await MapboxGL.offlineManager.invalidateAmbientCache();"
+        ],
+        "returns": {
+          "description": "",
+          "type": {
+            "name": "void"
+          }
+        }
+      },
       {
         "name": "resetDatabase",
         "description": "Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.",

@tsemerad
Copy link
Contributor Author

tsemerad commented Jun 3, 2020

Thanks @mfazekas. Sure enough, cloning a new copy of the repo as you laid out worked fine for me. The docs generated. There must be something wrong with my previous copy of the repo I was using months ago. I just updated the commit with the docs changes. Thanks!

In regards to including it in examples, I had decided against it because I'm not sure how we'd demonstrate it working. It kind of requires that the remote vector tiles change to see that it works and grabs the updated data. If you have an idea for an example I could add to, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants