63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
/**
|
|
* @flow
|
|
* Disconnect representation wrapper
|
|
*/
|
|
import { typeOf } from './../../utils';
|
|
import type Database from './';
|
|
import type Reference from './reference';
|
|
|
|
|
|
/**
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect
|
|
* @class Disconnect
|
|
*/
|
|
export default class Disconnect {
|
|
_database: Database;
|
|
ref: Reference;
|
|
path: string;
|
|
|
|
/**
|
|
*
|
|
* @param ref
|
|
*/
|
|
constructor(ref: Reference) {
|
|
this.ref = ref;
|
|
this.path = ref.path;
|
|
this._database = ref._database;
|
|
}
|
|
|
|
/**
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#set
|
|
* @param value
|
|
* @returns {*}
|
|
*/
|
|
set(value: string | Object): Promise<void> {
|
|
return this._database._native.onDisconnectSet(this.path, { type: typeOf(value), value });
|
|
}
|
|
|
|
/**
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#update
|
|
* @param values
|
|
* @returns {*}
|
|
*/
|
|
update(values: Object): Promise<void> {
|
|
return this._database._native.onDisconnectUpdate(this.path, values);
|
|
}
|
|
|
|
/**
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#remove
|
|
* @returns {*}
|
|
*/
|
|
remove(): Promise<void> {
|
|
return this._database._native.onDisconnectRemove(this.path);
|
|
}
|
|
|
|
/**
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#cancel
|
|
* @returns {*}
|
|
*/
|
|
cancel(): Promise<void> {
|
|
return this._database._native.onDisconnectCancel(this.path);
|
|
}
|
|
}
|