2017-12-04 12:07:41 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
2018-02-14 13:00:19 +00:00
|
|
|
* OnDisconnect representation wrapper
|
2017-12-04 12:07:41 +00:00
|
|
|
*/
|
2018-01-05 18:23:38 +00:00
|
|
|
import { typeOf } from '../../utils';
|
|
|
|
import { getNativeModule } from '../../utils/native';
|
2017-12-04 12:07:41 +00:00
|
|
|
import type Database from './';
|
2018-02-14 13:00:19 +00:00
|
|
|
import type Reference from './Reference';
|
2017-02-14 15:57:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect
|
2018-02-14 13:00:19 +00:00
|
|
|
* @class OmDisconnect
|
2017-02-14 15:57:08 +00:00
|
|
|
*/
|
2018-02-14 13:00:19 +00:00
|
|
|
export default class OnDisconnect {
|
2017-12-04 12:07:41 +00:00
|
|
|
_database: Database;
|
2017-02-14 15:57:08 +00:00
|
|
|
ref: Reference;
|
2017-04-04 16:58:20 +00:00
|
|
|
path: string;
|
2017-02-14 15:57:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-09-07 15:36:47 +00:00
|
|
|
* @param ref
|
2017-02-14 15:57:08 +00:00
|
|
|
*/
|
2017-09-07 15:36:47 +00:00
|
|
|
constructor(ref: Reference) {
|
|
|
|
this.ref = ref;
|
|
|
|
this.path = ref.path;
|
|
|
|
this._database = ref._database;
|
2017-02-14 15:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#set
|
|
|
|
* @param value
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2017-09-07 15:36:47 +00:00
|
|
|
set(value: string | Object): Promise<void> {
|
2018-01-25 18:25:39 +00:00
|
|
|
return getNativeModule(this._database).onDisconnectSet(this.path, {
|
|
|
|
type: typeOf(value),
|
|
|
|
value,
|
|
|
|
});
|
2017-02-14 15:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#update
|
|
|
|
* @param values
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2017-09-07 15:36:47 +00:00
|
|
|
update(values: Object): Promise<void> {
|
2018-01-25 18:25:39 +00:00
|
|
|
return getNativeModule(this._database).onDisconnectUpdate(
|
|
|
|
this.path,
|
|
|
|
values
|
|
|
|
);
|
2017-02-14 15:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#remove
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2017-09-07 15:36:47 +00:00
|
|
|
remove(): Promise<void> {
|
2018-01-05 18:23:38 +00:00
|
|
|
return getNativeModule(this._database).onDisconnectRemove(this.path);
|
2017-02-14 15:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#cancel
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2017-09-07 15:36:47 +00:00
|
|
|
cancel(): Promise<void> {
|
2018-01-05 18:23:38 +00:00
|
|
|
return getNativeModule(this._database).onDisconnectCancel(this.path);
|
2017-02-14 15:57:08 +00:00
|
|
|
}
|
|
|
|
}
|