Skip to content

Commit 4300141

Browse files
authored
Export getReactNativePersistence function (#5711)
1 parent 3281315 commit 4300141

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/auth/index.rn.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions
5959
export const reactNativeLocalPersistence: Persistence =
6060
getReactNativePersistence(AsyncStorage);
6161

62+
export {getReactNativePersistence};
63+
6264
export function getAuth(app: FirebaseApp = getApp()): Auth {
6365
const provider = _getProvider(app, 'auth');
6466

packages/auth/src/platform_react_native/persistence/react_native.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,21 @@ import {
2626
} from '../../core/persistence';
2727

2828
/**
29-
* Returns a persistence class that wraps AsyncStorage imported from
30-
* `react-native` or `@react-native-community/async-storage`.
31-
*
32-
* Creates a "new"-able subclass on the fly that has an empty constructor.
33-
*
34-
* In the _getInstance() implementation (see src/core/persistence/index.ts),
35-
* we expect each "externs.Persistence" object passed to us by the user to
36-
* be able to be instantiated (as a class) using "new". That function also
37-
* expects the constructor to be empty. Since ReactNativeStorage requires the
38-
* underlying storage layer, we need to be able to create subclasses
39-
* (closures, esentially) that have the storage layer but empty constructor.
29+
* Returns a persistence object that wraps AsyncStorage imported from
30+
* `react-native` or `@react-native-community/async-storage`, and can
31+
* be used in the persistence dependency field in {@link initializeAuth}.
32+
*
33+
* @public
4034
*/
41-
4235
export function getReactNativePersistence(
4336
storage: ReactNativeAsyncStorage
4437
): Persistence {
38+
// In the _getInstance() implementation (see src/core/persistence/index.ts),
39+
// we expect each "externs.Persistence" object passed to us by the user to
40+
// be able to be instantiated (as a class) using "new". That function also
41+
// expects the constructor to be empty. Since ReactNativeStorage requires the
42+
// underlying storage layer, we need to be able to create subclasses
43+
// (closures, esentially) that have the storage layer but empty constructor.
4544
return class implements PersistenceInternal {
4645
static type: 'LOCAL' = 'LOCAL';
4746
readonly type: PersistenceType = PersistenceType.LOCAL;

0 commit comments

Comments
 (0)