Skip to content

Commit 857dbcd

Browse files
authored
Use rxfire/remote-config for remote config getters (#434)
1 parent 24320c4 commit 857dbcd

File tree

5 files changed

+11
-217
lines changed

5 files changed

+11
-217
lines changed

docs/reference/README.md

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/modules/remote_config.md

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/modules/remote_config_getValue.md

Lines changed: 0 additions & 135 deletions
This file was deleted.

src/remote-config/index.tsx renamed to src/remote-config.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
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';
44
import { Observable } from 'rxjs';
55

66
import type { RemoteConfig, Value as RemoteConfigValue } from 'firebase/remote-config';
77

88
type 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 {
2318
function 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
*/
4234
export 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
*/
5142
export 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
*/
6050
export 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
*/
6958
export 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
*/
7866
export function useRemoteConfigAll(key: string): ObservableStatus<AllParameters> {
7967
return useRemoteConfigValue_INTERNAL<AllParameters>(key, getAll);

src/remote-config/getValue.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)