prefetchCredentials method

Future<PowerSyncCredentials?> prefetchCredentials()

Fetch a new set of credentials and cache it.

Until this call succeeds, getCredentialsCached() will still return the old credentials.

This may be called before the current credentials have expired.

Implementation

Future<PowerSyncCredentials?> prefetchCredentials() async {
  _fetchRequest ??= fetchCredentials().then((value) {
    _cachedCredentials = value;
    return value;
  }).whenComplete(() {
    _fetchRequest = null;
  });

  return _fetchRequest!;
}