-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move cache snapshot loading to Visit#start() (#1056)
* Move cache snapshot loading to Visit#start() The cache interface changed in #949 Since the cache can be loaded from disk using the browser Cache API, it is possible that the cache snapshot will be loaded asynchronously. This means that the calls to load cache snapshots need to be awaited. We also changed visit.hasCachedSnapshot() to be async and return a Promise. However, [hasCachedSnapshot is used in the iOS adapter](https://github.com/hotwired/turbo-ios/blob/c476bac66f260adbfe930ed9a151e7637973ff99/Source/WebView/turbo.js#L119) and serialized into and data object we send to the native side via postMessage. When postMessagereceives a Promise instead of a boolean value it fails with a DataCloneError since it can't serialize the Promise. This commit moves the cache snapshot loading to Visit#start() and stores the result in a cachedSnapshot property. This allows us to keep the hasCachedSnapshot() method synchronous and return a boolean value. It means that Visit.start is now async, but I haven't found any callers that rely on it being synchronous. * Explicitly test that visit.hasCachedSnapshot() returns a boolean, which is what the native adapters expect * Remove the "test " prefix from the native adapter unit tests, since other tests were recently updated to remove the prefix --------- Co-authored-by: Jay Ohms <jay.ohms@gmail.com>
- Loading branch information
Showing
4 changed files
with
37 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters