enablePersistence method

Future<void> enablePersistence([
  1. PersistenceSettings? settings
])

Attempts to enable persistent storage, if possible.

Must be called before any other methods (other than settings()).

If this fails, enablePersistence() will reject the Future it returns. Note that even after this failure, the firestore instance will remain usable, however offline persistence will be disabled.

There are several reasons why this can fail, which can be identified by the code on the error.

  • failed-precondition: The app is already open in another browser tab.
  • unimplemented: The browser is incompatible with the offline persistence implementation.

Returns non-null Future that represents successfully enabling persistent storage.

Implementation

Future<void> enablePersistence([PersistenceSettings? settings]) =>
    handleThenable(jsObject.enablePersistence(settings));