Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(fields, mapValue = mapValueIdent) {
Object.keys(fields).forEach(name =>
invariant(isEmitter(fields[name]), 'FirebaseStruct fields values must be emitters')
);
invariant(isFunction(mapValue), 'FirebaseStruct second arg must be a function');
super();
this.fields = fields;
this.mapValue = mapValue;
this.reset();
}
constructor(ref, mapChild, { idField = 'id', instant = true, mapKey = getKey } = {}) {
invariant(isEmitter(ref), 'FirebaseList first arg must be emitter');
invariant(isFunction(mapChild), 'FirebaseList second arg must be a function');
invariant(isFunction(mapKey), 'FirebaseList `mapKey` option must be a function');
super();
this.ref = ref;
this.mapChild = mapChild;
this.idField = idField;
this.instant = instant;
this.hasInitialData = !instant;
this.mapKey = mapKey;
this.reset();
}
_getInnerErrorCode(error) {
if (!isFunction(error.getInnerError)) return;
let innerError = error.getInnerError();
if (!innerError) return;
if (
isFunction(innerError.getErrorCode) &&
isFunction(innerError.getVastErrorCode)
)
return (
innerError.getErrorCode().toString() ||
innerError.getVastErrorCode().toString()
);
return innerError.message;
}
function flush() {
if (nextData !== NO_VALUE && !isEqual(nextData, lastData) && isFunction(nextCallback)) {
[callbackCopy, nextCallback, lastData, nextData] = [nextCallback, null, nextData, NO_VALUE];
callbackCopy(null, lastData);
}
}
getTheme(passedTheme) {
const theme = passedTheme || this.props.theme
if (isFunction(theme)) {
const mergedTheme = theme(this.outerTheme)
if (!isPlainObject(mergedTheme)) {
throw new Error(
'[ThemeProvider] Please return an object from your theme function, ' +
'i.e. theme={() => ({})}!',
)
}
return mergedTheme
}
return {...this.outerTheme, ...theme}
}
getTheme(passedTheme: (outherTheme: Theme) => void | Theme) {
const theme = passedTheme || this.props.theme
if (isFunction(theme)) {
const mergedTheme = theme(this.outerTheme)
if (!isPlainObject(mergedTheme)) {
throw new Error('[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!')
}
return mergedTheme
}
if (!isPlainObject(theme)) {
throw new Error('[ThemeProvider] Please make your theme prop a plain object')
}
return { ...this.outerTheme, ...(theme: Object) }
}
_getInnerErrorCode(error) {
if (!isFunction(error.getInnerError)) return;
let innerError = error.getInnerError();
if (!innerError) return;
if (
isFunction(innerError.getErrorCode) &&
isFunction(innerError.getVastErrorCode)
)
return (
innerError.getErrorCode().toString() ||
innerError.getVastErrorCode().toString()
);
return innerError.message;
}
constructor(ref, mapChild, { idField = 'id', instant = true, mapKey = getKey } = {}) {
invariant(isEmitter(ref), 'FirebaseList first arg must be emitter');
invariant(isFunction(mapChild), 'FirebaseList second arg must be a function');
invariant(isFunction(mapKey), 'FirebaseList `mapKey` option must be a function');
super();
this.ref = ref;
this.mapChild = mapChild;
this.idField = idField;
this.instant = instant;
this.hasInitialData = !instant;
this.mapKey = mapKey;
this.reset();
}