Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onDisconnectUpdate(
path: Path,
childrenToMerge: { [k: string]: any },
onComplete: ((status: Error | null, errorReason?: string) => void) | null
) {
if (isEmpty(childrenToMerge)) {
log(
"onDisconnect().update() called with empty data. Don't do anything."
);
this.callOnCompleteCallback(onComplete, 'ok');
return;
}
this.server_.onDisconnectMerge(
path.toString(),
childrenToMerge,
(status, errorReason) => {
if (status === 'ok') {
each(childrenToMerge, (childName: string, childNode: any) => {
const newChildNode = nodeFromJSON(childNode);
this.onDisconnect_.remember(path.child(childName), newChildNode);
});
resume(reason: string) {
log('Resuming connection for reason: ' + reason);
delete this.interruptReasons_[reason];
if (isEmpty(this.interruptReasons_)) {
this.reconnectDelay_ = RECONNECT_MIN_DELAY;
if (!this.realtime_) {
this.scheduleConnect_(0);
}
}
}
private shouldReconnect_(): boolean {
const online = OnlineMonitor.getInstance().currentlyOnline();
return isEmpty(this.interruptReasons_) && online;
}
}
private shouldReconnect_(): boolean {
const online = OnlineMonitor.getInstance().currentlyOnline();
return isEmpty(this.interruptReasons_) && online;
}
}
resume(reason: string) {
log('Resuming connection for reason: ' + reason);
delete this.interruptReasons_[reason];
if (isEmpty(this.interruptReasons_)) {
this.reconnectDelay_ = RECONNECT_MIN_DELAY;
if (!this.realtime_) {
this.scheduleConnect_(0);
}
}
}
onDisconnectUpdate(
path: Path,
childrenToMerge: { [k: string]: any },
onComplete: ((status: Error | null, errorReason?: string) => void) | null
) {
if (isEmpty(childrenToMerge)) {
log(
"onDisconnect().update() called with empty data. Don't do anything."
);
this.callOnCompleteCallback(onComplete, 'ok');
return;
}
this.server_.onDisconnectMerge(
path.toString(),
childrenToMerge,
(status, errorReason) => {
if (status === 'ok') {
each(childrenToMerge, (childName: string, childNode: any) => {
const newChildNode = nodeFromJSON(childNode);
this.onDisconnect_.remember(path.child(childName), newChildNode);
});
isEmpty(): boolean {
return isEmpty(this.set);
}