Modifies push() to return ThenableReference
This commit is contained in:
parent
44e005b58d
commit
47438a459c
@ -299,15 +299,15 @@ export default class Reference extends ReferenceBase {
|
|||||||
* @param onComplete
|
* @param onComplete
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
push(value: any, onComplete?: Function): Reference | Promise<void> {
|
push(value: any, onComplete?: Function): ThenableReference<void> {
|
||||||
if (value === null || value === undefined) {
|
if (value === null || value === undefined) {
|
||||||
return new Reference(
|
return new ThenableReference(
|
||||||
this._database,
|
this._database,
|
||||||
`${this.path}/${generatePushID(this._database._serverTimeOffset)}`
|
`${this.path}/${generatePushID(this._database._serverTimeOffset)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newRef = new Reference(
|
const newRef = new ThenableReference(
|
||||||
this._database,
|
this._database,
|
||||||
`${this.path}/${generatePushID(this._database._serverTimeOffset)}`
|
`${this.path}/${generatePushID(this._database._serverTimeOffset)}`
|
||||||
);
|
);
|
||||||
@ -890,3 +890,12 @@ export default class Reference extends ReferenceBase {
|
|||||||
return SyncTree.removeListenersForRegistrations(registrations);
|
return SyncTree.removeListenersForRegistrations(registrations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
declare class ThenableReference<+R> extends Reference {
|
||||||
|
then<U>(
|
||||||
|
onFulfill?: (value: R) => Promise<U> | U,
|
||||||
|
onReject?: (error: any) => Promise<U> | U
|
||||||
|
): Promise<U>;
|
||||||
|
catch<U>(onReject?: (error: any) => Promise<U> | U): Promise<R | U>;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user