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 ' ;
4
4
import { Observable } from 'rxjs' ;
5
5
6
6
import type { RemoteConfig , Value as RemoteConfigValue } from 'firebase/remote-config' ;
7
7
8
8
type Getter$ < T > = ( remoteConfig : RemoteConfig , key : string ) => Observable < T > ;
9
9
10
- interface RemoteConfigWithPrivate extends RemoteConfig {
11
- // This is a private API, assume optional
12
- _storage ?: { appName : string } ;
13
- }
14
-
15
10
/**
16
11
* Helper function to construct type safe functions. Since Remote Config has
17
12
* methods that return different types for values, we need to be extra safe
@@ -23,9 +18,7 @@ interface RemoteConfigWithPrivate extends RemoteConfig {
23
18
function useRemoteConfigValue_INTERNAL < T > ( key : string , getter : Getter$ < T > ) : ObservableStatus < T > {
24
19
const remoteConfig = useRemoteConfig ( ) ;
25
20
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 ;
29
22
const $value = getter ( remoteConfig , key ) ;
30
23
31
24
const observableId = `remoteConfig:${ key } :${ getter . name } :${ appName } ` ;
@@ -37,7 +30,6 @@ function useRemoteConfigValue_INTERNAL<T>(key: string, getter: Getter$<T>): Obse
37
30
* Remote Config Value.
38
31
*
39
32
* @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.
41
33
*/
42
34
export function useRemoteConfigValue ( key : string ) : ObservableStatus < RemoteConfigValue > {
43
35
return useRemoteConfigValue_INTERNAL < RemoteConfigValue > ( key , getValue ) ;
@@ -46,7 +38,6 @@ export function useRemoteConfigValue(key: string): ObservableStatus<RemoteConfig
46
38
/**
47
39
* Convience method similar to useRemoteConfigValue. Returns a `string` from a Remote Config parameter.
48
40
* @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.
50
41
*/
51
42
export function useRemoteConfigString ( key : string ) : ObservableStatus < string > {
52
43
return useRemoteConfigValue_INTERNAL < string > ( key , getString ) ;
@@ -55,7 +46,6 @@ export function useRemoteConfigString(key: string): ObservableStatus<string> {
55
46
/**
56
47
* Convience method similar to useRemoteConfigValue. Returns a `number` from a Remote Config parameter.
57
48
* @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.
59
49
*/
60
50
export function useRemoteConfigNumber ( key : string ) : ObservableStatus < number > {
61
51
return useRemoteConfigValue_INTERNAL < number > ( key , getNumber ) ;
@@ -64,7 +54,6 @@ export function useRemoteConfigNumber(key: string): ObservableStatus<number> {
64
54
/**
65
55
* Convience method similar to useRemoteConfigValue. Returns a `boolean` from a Remote Config parameter.
66
56
* @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.
68
57
*/
69
58
export function useRemoteConfigBoolean ( key : string ) : ObservableStatus < boolean > {
70
59
return useRemoteConfigValue_INTERNAL < boolean > ( key , getBoolean ) ;
@@ -73,7 +62,6 @@ export function useRemoteConfigBoolean(key: string): ObservableStatus<boolean> {
73
62
/**
74
63
* Convience method similar to useRemoteConfigValue. Returns allRemote Config parameters.
75
64
* @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.
77
65
*/
78
66
export function useRemoteConfigAll ( key : string ) : ObservableStatus < AllParameters > {
79
67
return useRemoteConfigValue_INTERNAL < AllParameters > ( key , getAll ) ;
0 commit comments