[internals][js] remove legacy options
arg for module constructors and cleanup constructor args
This commit is contained in:
parent
a2205160d8
commit
a2c56a5be4
@ -32,17 +32,21 @@ export default class Database extends ModuleBase {
|
||||
|
||||
_serviceUrl: string;
|
||||
|
||||
constructor(appOrUrl: App | string, options: Object = {}) {
|
||||
constructor(appOrCustomUrl: App | string, customUrl?: string) {
|
||||
let app;
|
||||
let serviceUrl;
|
||||
if (typeof appOrUrl === 'string') {
|
||||
let url;
|
||||
|
||||
if (typeof appOrCustomUrl === 'string') {
|
||||
app = firebase.app();
|
||||
serviceUrl = appOrUrl.endsWith('/') ? appOrUrl : `${appOrUrl}/`;
|
||||
url = appOrCustomUrl;
|
||||
} else {
|
||||
app = appOrUrl;
|
||||
serviceUrl = app.options.databaseURL;
|
||||
app = appOrCustomUrl;
|
||||
url = customUrl || app.options.databaseURL;
|
||||
}
|
||||
|
||||
// enforce trailing slash
|
||||
url = url.endsWith('/') ? url : `${url}/`;
|
||||
|
||||
super(
|
||||
app,
|
||||
{
|
||||
@ -52,15 +56,15 @@ export default class Database extends ModuleBase {
|
||||
hasCustomUrlSupport: true,
|
||||
namespace: NAMESPACE,
|
||||
},
|
||||
serviceUrl
|
||||
url
|
||||
);
|
||||
|
||||
this._serverTimeOffset = 0;
|
||||
this._serviceUrl = serviceUrl;
|
||||
this._transactionHandler = new TransactionHandler(this);
|
||||
|
||||
if (options.persistence) {
|
||||
getNativeModule(this).setPersistence(options.persistence);
|
||||
if (app.options.persistence) {
|
||||
getNativeModule(this).setPersistence(app.options.persistence);
|
||||
}
|
||||
|
||||
// server time listener
|
||||
|
@ -40,16 +40,19 @@ function errorOrResult(possibleError): HttpsCallablePromise {
|
||||
return Promise.resolve(possibleError);
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------
|
||||
* functions()
|
||||
* -------------
|
||||
*/
|
||||
export default class Functions extends ModuleBase {
|
||||
_region: string;
|
||||
|
||||
constructor(appOrRegion: App, region: string = 'us-central1') {
|
||||
constructor(appOrRegion: App, region?: string = 'us-central1') {
|
||||
let _app = appOrRegion;
|
||||
let _region = region;
|
||||
|
||||
if (typeof appOrRegion === 'string') {
|
||||
if (typeof _app === 'string') {
|
||||
_region = _app;
|
||||
_app = firebase.app();
|
||||
_region = appOrRegion;
|
||||
}
|
||||
|
||||
super(
|
||||
@ -77,7 +80,7 @@ export default class Functions extends ModuleBase {
|
||||
*/
|
||||
httpsCallable(name: string): HttpsCallable {
|
||||
return (data?: any): HttpsCallablePromise => {
|
||||
const promise = getNativeModule(this).httpsCallable(this._region, name, {
|
||||
const promise = getNativeModule(this).httpsCallable(name, {
|
||||
data,
|
||||
});
|
||||
|
||||
|
@ -69,8 +69,8 @@ export default {
|
||||
|
||||
if (!APP_MODULES[appInstanceIdentifier][namespace]) {
|
||||
APP_MODULES[appInstanceIdentifier][namespace] = new InstanceClass(
|
||||
customUrlOrRegion || app,
|
||||
app.options
|
||||
app,
|
||||
customUrlOrRegion
|
||||
);
|
||||
|
||||
// only check once on new app namespace instance
|
||||
@ -185,9 +185,12 @@ export default {
|
||||
statics: S,
|
||||
moduleName: FirebaseModuleName
|
||||
): FirebaseModuleAndStatics<M, S> {
|
||||
const getModule = (appOrUrlOrRegion?: App | string): FirebaseModule => {
|
||||
const getModule = (
|
||||
appOrUrlOrRegion?: App | string,
|
||||
customUrlOrRegion?: string
|
||||
): FirebaseModule => {
|
||||
let _app = appOrUrlOrRegion;
|
||||
let _customUrlOrRegion: ?string = null;
|
||||
let _customUrlOrRegion: ?string = customUrlOrRegion || null;
|
||||
|
||||
if (typeof appOrUrlOrRegion === 'string' && namespace === 'database') {
|
||||
_app = null;
|
||||
|
@ -42,7 +42,13 @@ export const initialiseNativeModule = (
|
||||
config: FirebaseModuleConfig,
|
||||
customUrlOrRegion: ?string
|
||||
): Object => {
|
||||
const { moduleName, hasMultiAppSupport, hasCustomUrlSupport, hasRegionsSupport, namespace } = config;
|
||||
const {
|
||||
moduleName,
|
||||
hasMultiAppSupport,
|
||||
hasCustomUrlSupport,
|
||||
hasRegionsSupport,
|
||||
namespace,
|
||||
} = config;
|
||||
const nativeModule = NativeModules[moduleName];
|
||||
const key = nativeModuleKey(module);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user