Merge pull request #1226 from Ken-Lim/master

Add type definition for RemoteConfig module
This commit is contained in:
Chris Bianca 2018-06-19 07:13:37 +01:00 committed by GitHub
commit 90febd6f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 64 additions and 2 deletions

66
lib/index.d.ts vendored
View File

@ -25,7 +25,7 @@ declare module 'react-native-firebase' {
RNFirebase.auth.Auth,
RNFirebase.auth.AuthStatics
>;
// config: FirebaseModule<RNFirebase.config.Config>;
config: FirebaseModuleAndStatics<RNFirebase.config.Config>;
crash: FirebaseModuleAndStatics<RNFirebase.crash.Crash>;
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
database: FirebaseModuleAndStatics<
@ -81,7 +81,7 @@ declare module 'react-native-firebase' {
// admob(): RNFirebase.admob.AdMob;
analytics(): RNFirebase.Analytics;
auth(): RNFirebase.auth.Auth;
// config(): RNFirebase.config.Config;
config(): RNFirebase.config.Config;
crash(): RNFirebase.crash.Crash;
crashlytics(): RNFirebase.crashlytics.Crashlytics;
database(): RNFirebase.database.Database;
@ -1483,6 +1483,68 @@ declare module 'react-native-firebase' {
}
}
namespace config {
interface ConfigSnapshot {
source: string;
val(): any;
}
interface Object<ConfigSnapshot> {
[key: string]: ConfigSnapshot;
}
interface Config {
/** Enable Remote Config developer mode to allow for frequent refreshes of the cache. */
enableDeveloperMode(): void;
/**
* Sets default values for the app to use when accessing values.
* Any data fetched and activated will override any default values.
* Any values in the defaults but not on Firebase will be untouched.
*/
setDefaults(defaults: object): void;
/**
* Fetches the remote config data from Firebase, defined in the dashboard.
* If duration is defined (seconds), data will be locally cached for this duration.
*
* The default duration is 43200 seconds (12 hours).
* To force a cache refresh call the method with a duration of 0.
*/
fetch(duration?: number): Promise<void>;
/**
* Fetches the remote config data from Firebase, defined in the dashboard.
* The default expiration duration is 43200 seconds (12 hours)
*/
activateFetched(): Promise<boolean>;
/**
* Gets a config item by key.
* Returns a snapshot containing source (default, remote or static) and val function.
*/
getValue(key: string): Promise<ConfigSnapshot>;
/**
* Gets multiple values by key.
* Returns a snapshot object with snapshot keys e.g. snapshots.foo.val().
*/
getValues(array: Array<string>): Promise<Object<ConfigSnapshot>>;
/**
* Returns all keys as an array by a prefix. If no prefix is defined all keys are returned.
*/
getKeysByPrefix(prefix?: string): Promise<Array<String>>;
/**
* Sets the default values from a resource:
* - Android: Id for the XML resource, which should be in your application's res/xml folder.
* - iOS: The plist file name, with no file name extension.
*/
setDefaultsFromResource(resource: string | number): void;
}
}
namespace crash {
interface Crash {
/** Logs a message that will appear in a subsequent crash report. */