1- import { useRemoteConfig } from '.. /' ;
2- import { useObservable , ObservableStatus } from '.. /useObservable' ;
3- import { getValue , getString , getBoolean , getNumber , getAll , AllParameters } from './getValue ' ;
1+ import { useRemoteConfig } from './' ;
2+ import { useObservable , ObservableStatus } from './useObservable' ;
3+ import { getValue , getString , getBoolean , getNumber , getAll , AllParameters } from 'rxfire/remote-config ' ;
44import { Observable } from 'rxjs' ;
55
66import type { RemoteConfig , Value as RemoteConfigValue } from 'firebase/remote-config' ;
77
88type Getter$ < T > = ( remoteConfig : RemoteConfig , key : string ) => Observable < T > ;
99
10- interface RemoteConfigWithPrivate extends RemoteConfig {
11- // This is a private API, assume optional
12- _storage ?: { appName : string } ;
13- }
14-
1510/**
1611 * Helper function to construct type safe functions. Since Remote Config has
1712 * methods that return different types for values, we need to be extra safe
@@ -23,9 +18,7 @@ interface RemoteConfigWithPrivate extends RemoteConfig {
2318function useRemoteConfigValue_INTERNAL < T > ( key : string , getter : Getter$ < T > ) : ObservableStatus < T > {
2419 const remoteConfig = useRemoteConfig ( ) ;
2520
26- // INVESTIGATE need to use a public API to get at the app name, one doesn't appear to exist...
27- // we might need to iterate over the Firebase apps and check for remoteConfig equality? this works for now
28- const appName = ( remoteConfig as RemoteConfigWithPrivate ) . _storage ?. appName ;
21+ const appName = remoteConfig . app . name ;
2922 const $value = getter ( remoteConfig , key ) ;
3023
3124 const observableId = `remoteConfig:${ key } :${ getter . name } :${ appName } ` ;
@@ -37,7 +30,6 @@ function useRemoteConfigValue_INTERNAL<T>(key: string, getter: Getter$<T>): Obse
3730 * Remote Config Value.
3831 *
3932 * @param key The parameter key in Remote Config
40- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
4133 */
4234export function useRemoteConfigValue ( key : string ) : ObservableStatus < RemoteConfigValue > {
4335 return useRemoteConfigValue_INTERNAL < RemoteConfigValue > ( key , getValue ) ;
@@ -46,7 +38,6 @@ export function useRemoteConfigValue(key: string): ObservableStatus<RemoteConfig
4638/**
4739 * Convience method similar to useRemoteConfigValue. Returns a `string` from a Remote Config parameter.
4840 * @param key The parameter key in Remote Config
49- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
5041 */
5142export function useRemoteConfigString ( key : string ) : ObservableStatus < string > {
5243 return useRemoteConfigValue_INTERNAL < string > ( key , getString ) ;
@@ -55,7 +46,6 @@ export function useRemoteConfigString(key: string): ObservableStatus<string> {
5546/**
5647 * Convience method similar to useRemoteConfigValue. Returns a `number` from a Remote Config parameter.
5748 * @param key The parameter key in Remote Config
58- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
5949 */
6050export function useRemoteConfigNumber ( key : string ) : ObservableStatus < number > {
6151 return useRemoteConfigValue_INTERNAL < number > ( key , getNumber ) ;
@@ -64,7 +54,6 @@ export function useRemoteConfigNumber(key: string): ObservableStatus<number> {
6454/**
6555 * Convience method similar to useRemoteConfigValue. Returns a `boolean` from a Remote Config parameter.
6656 * @param key The parameter key in Remote Config
67- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
6857 */
6958export function useRemoteConfigBoolean ( key : string ) : ObservableStatus < boolean > {
7059 return useRemoteConfigValue_INTERNAL < boolean > ( key , getBoolean ) ;
@@ -73,7 +62,6 @@ export function useRemoteConfigBoolean(key: string): ObservableStatus<boolean> {
7362/**
7463 * Convience method similar to useRemoteConfigValue. Returns allRemote Config parameters.
7564 * @param key The parameter key in Remote Config
76- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
7765 */
7866export function useRemoteConfigAll ( key : string ) : ObservableStatus < AllParameters > {
7967 return useRemoteConfigValue_INTERNAL < AllParameters > ( key , getAll ) ;
0 commit comments