2
0
mirror of synced 2025-01-10 22:26:02 +00:00
2017-04-04 17:58:20 +01:00

59 lines
1.4 KiB
JavaScript

/* @flow */
import { NativeModules } from 'react-native';
import { promisify, typeOf } from './../../utils';
import Reference from './reference';
const FirebaseDatabase = NativeModules.RNFirebaseDatabase;
/**
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect
* @class Disconnect
*/
export default class Disconnect {
ref: Reference;
path: string;
/**
*
* @param path Reference Path
*/
constructor(path: string) {
this.path = path;
}
/**
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#set
* @param value
* @returns {*}
*/
set(value: string | Object) {
return promisify('onDisconnectSet', FirebaseDatabase)(this.path, { type: typeOf(value), value });
}
/**
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#update
* @param values
* @returns {*}
*/
update(values: Object) {
return promisify('onDisconnectUpdate', FirebaseDatabase)(this.path, values);
}
/**
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#remove
* @returns {*}
*/
remove() {
return promisify('onDisconnectRemove', FirebaseDatabase)(this.path);
}
/**
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect#cancel
* @returns {*}
*/
cancel() {
return promisify('onDisconnectCancel', FirebaseDatabase)(this.path);
}
}