[js][database] fix OnDisconnect incorrectly being constructed + added misc typings
This commit is contained in:
parent
3f9cd5435e
commit
557face5eb
|
@ -105,4 +105,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9
|
||||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||||
|
|
||||||
[version]
|
[version]
|
||||||
^0.40.0
|
^0.46.0
|
||||||
|
|
|
@ -14,10 +14,12 @@ export default class Disconnect {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param path Reference Path
|
* @param ref
|
||||||
*/
|
*/
|
||||||
constructor(path: string) {
|
constructor(ref: Reference) {
|
||||||
this.path = path;
|
this.ref = ref;
|
||||||
|
this.path = ref.path;
|
||||||
|
this._database = ref._database;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,8 +27,8 @@ export default class Disconnect {
|
||||||
* @param value
|
* @param value
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
set(value: string | Object) {
|
set(value: string | Object): Promise<void> {
|
||||||
return this.database._native.onDisconnectSet(this.path, { type: typeOf(value), value });
|
return this._database._native.onDisconnectSet(this.path, { type: typeOf(value), value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,23 +36,23 @@ export default class Disconnect {
|
||||||
* @param values
|
* @param values
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
update(values: Object) {
|
update(values: Object): Promise<void> {
|
||||||
return this.database._native.onDisconnectUpdate(this.path, values);
|
return this._database._native.onDisconnectUpdate(this.path, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#remove
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#remove
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
remove() {
|
remove(): Promise<void> {
|
||||||
return this.database._native.onDisconnectRemove(this.path);
|
return this._database._native.onDisconnectRemove(this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#cancel
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#cancel
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
cancel() {
|
cancel(): Promise<void> {
|
||||||
return this.database._native.onDisconnectCancel(this.path);
|
return this._database._native.onDisconnectCancel(this.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ export default class Reference extends ReferenceBase {
|
||||||
* @param onComplete
|
* @param onComplete
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
push(value: any, onComplete?: Function) {
|
push(value: any, onComplete?: Function): Reference | Promise {
|
||||||
if (value === null || value === undefined) {
|
if (value === null || value === undefined) {
|
||||||
return new Reference(this._database, `${this.path}/${generatePushID(this._database.serverTimeOffset)}`);
|
return new Reference(this._database, `${this.path}/${generatePushID(this._database.serverTimeOffset)}`);
|
||||||
}
|
}
|
||||||
|
@ -403,8 +403,8 @@ export default class Reference extends ReferenceBase {
|
||||||
*
|
*
|
||||||
* @returns {Disconnect}
|
* @returns {Disconnect}
|
||||||
*/
|
*/
|
||||||
onDisconnect() {
|
onDisconnect(): Disconnect {
|
||||||
return new Disconnect(this.path);
|
return new Disconnect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -415,7 +415,7 @@ export default class Reference extends ReferenceBase {
|
||||||
* Reference
|
* Reference
|
||||||
* {@link https://firebase.google.com/docs/reference/js/firebase.database.Reference#child}
|
* {@link https://firebase.google.com/docs/reference/js/firebase.database.Reference#child}
|
||||||
*/
|
*/
|
||||||
child(path: string) {
|
child(path: string): Reference {
|
||||||
return new Reference(this._database, `${this.path}/${path}`);
|
return new Reference(this._database, `${this.path}/${path}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue