Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/reference/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions docs/reference/modules/remote_config.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 0 additions & 135 deletions docs/reference/modules/remote_config_getValue.md

This file was deleted.

20 changes: 4 additions & 16 deletions src/remote-config/index.tsx → src/remote-config.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { useRemoteConfig } from '../';
import { useObservable, ObservableStatus } from '../useObservable';
import { getValue, getString, getBoolean, getNumber, getAll, AllParameters } from './getValue';
import { useRemoteConfig } from './';
import { useObservable, ObservableStatus } from './useObservable';
import { getValue, getString, getBoolean, getNumber, getAll, AllParameters } from 'rxfire/remote-config';
import { Observable } from 'rxjs';

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

type Getter$<T> = (remoteConfig: RemoteConfig, key: string) => Observable<T>;

interface RemoteConfigWithPrivate extends RemoteConfig {
// This is a private API, assume optional
_storage?: { appName: string };
}

/**
* Helper function to construct type safe functions. Since Remote Config has
* methods that return different types for values, we need to be extra safe
Expand All @@ -23,9 +18,7 @@ interface RemoteConfigWithPrivate extends RemoteConfig {
function useRemoteConfigValue_INTERNAL<T>(key: string, getter: Getter$<T>): ObservableStatus<T> {
const remoteConfig = useRemoteConfig();

// INVESTIGATE need to use a public API to get at the app name, one doesn't appear to exist...
// we might need to iterate over the Firebase apps and check for remoteConfig equality? this works for now
const appName = (remoteConfig as RemoteConfigWithPrivate)._storage?.appName;
const appName = remoteConfig.app.name;
const $value = getter(remoteConfig, key);

const observableId = `remoteConfig:${key}:${getter.name}:${appName}`;
Expand All @@ -37,7 +30,6 @@ function useRemoteConfigValue_INTERNAL<T>(key: string, getter: Getter$<T>): Obse
* Remote Config Value.
*
* @param key The parameter key in Remote Config
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
*/
export function useRemoteConfigValue(key: string): ObservableStatus<RemoteConfigValue> {
return useRemoteConfigValue_INTERNAL<RemoteConfigValue>(key, getValue);
Expand All @@ -46,7 +38,6 @@ export function useRemoteConfigValue(key: string): ObservableStatus<RemoteConfig
/**
* Convience method similar to useRemoteConfigValue. Returns a `string` from a Remote Config parameter.
* @param key The parameter key in Remote Config
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
*/
export function useRemoteConfigString(key: string): ObservableStatus<string> {
return useRemoteConfigValue_INTERNAL<string>(key, getString);
Expand All @@ -55,7 +46,6 @@ export function useRemoteConfigString(key: string): ObservableStatus<string> {
/**
* Convience method similar to useRemoteConfigValue. Returns a `number` from a Remote Config parameter.
* @param key The parameter key in Remote Config
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
*/
export function useRemoteConfigNumber(key: string): ObservableStatus<number> {
return useRemoteConfigValue_INTERNAL<number>(key, getNumber);
Expand All @@ -64,7 +54,6 @@ export function useRemoteConfigNumber(key: string): ObservableStatus<number> {
/**
* Convience method similar to useRemoteConfigValue. Returns a `boolean` from a Remote Config parameter.
* @param key The parameter key in Remote Config
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
*/
export function useRemoteConfigBoolean(key: string): ObservableStatus<boolean> {
return useRemoteConfigValue_INTERNAL<boolean>(key, getBoolean);
Expand All @@ -73,7 +62,6 @@ export function useRemoteConfigBoolean(key: string): ObservableStatus<boolean> {
/**
* Convience method similar to useRemoteConfigValue. Returns allRemote Config parameters.
* @param key The parameter key in Remote Config
* @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
*/
export function useRemoteConfigAll(key: string): ObservableStatus<AllParameters> {
return useRemoteConfigValue_INTERNAL<AllParameters>(key, getAll);
Expand Down
58 changes: 0 additions & 58 deletions src/remote-config/getValue.tsx

This file was deleted.