Skip to content

Commit f24a204

Browse files
stopachkamikehardy
andauthored
docs(database, offline): setPersistence* methods are sync not async (#5887)
* Promise -> Sync: setPersistence* #5886 `setPeristenceEnabled` and `setPersistenceCacheSizeBytes` are sync calls, which do not return a promise. Currently the examples expect a promise. This fixes them to expect a sync call. * fix(database, types): setPersistence* and setLogging are sync Co-authored-by: Mike Hardy <[email protected]>
1 parent 0025d8c commit f24a204

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

docs/database/offline-support.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ as early on in your application code as possible:
1919
import { AppRegistry } from 'react-native';
2020
import database from '@react-native-firebase/database';
2121

22-
database()
23-
.setPersistenceEnabled(true)
24-
.then(() => console.log('Realtime Database persistence enabled'));
22+
database().setPersistenceEnabled(true);
2523

2624
AppRegistry.registerComponent('app', () => App);
2725
```
@@ -93,5 +91,5 @@ little or too much data, call the `setPersistenceCacheSizeBytes` method to updat
9391
```js
9492
import database from '@react-native-firebase/database';
9593

96-
await database().setPersistenceCacheSizeBytes(2000000); // 2MB
94+
database().setPersistenceCacheSizeBytes(2000000); // 2MB
9795
```

packages/database/lib/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ export namespace FirebaseDatabaseTypes {
12171217
*
12181218
* @param enabled Whether persistence is enabled for the Database service.
12191219
*/
1220-
setPersistenceEnabled(enabled: boolean): Promise<void>;
1220+
setPersistenceEnabled(enabled: boolean): void;
12211221

12221222
/**
12231223
* Sets the native logging level for the database module. By default,
@@ -1237,7 +1237,7 @@ export namespace FirebaseDatabaseTypes {
12371237
*
12381238
* @param enabled Whether debug logging is enabled.
12391239
*/
1240-
setLoggingEnabled(enabled: boolean): Promise<void>;
1240+
setLoggingEnabled(enabled: boolean): void;
12411241

12421242
/**
12431243
* By default Firebase Database will use up to 10MB of disk space to cache data. If the cache grows beyond this size,
@@ -1262,7 +1262,7 @@ export namespace FirebaseDatabaseTypes {
12621262
*
12631263
* @param bytes The new size of the cache in bytes.
12641264
*/
1265-
setPersistenceCacheSizeBytes(bytes: number): Promise<void>;
1265+
setPersistenceCacheSizeBytes(bytes: number): void;
12661266

12671267
/**
12681268
* Modify this Database instance to communicate with the Firebase Database emulator.

0 commit comments

Comments
 (0)