react-native-firebase/lib/modules/database/disconnect.js

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-02-14 15:57:08 +00:00
/* @flow */
import { NativeModules } from 'react-native';
import { promisify, typeOf } from './../../utils';
import Reference from './reference';
2017-03-02 13:09:41 +00:00
const FirebaseDatabase = NativeModules.RNFirebaseDatabase;
2017-02-14 15:57:08 +00:00
/**
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect
* @class Disconnect
*/
export default class Disconnect {
ref: Reference;
2017-04-04 16:58:20 +00:00
path: string;
2017-02-14 15:57:08 +00:00
/**
*
* @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) {
2017-02-15 12:14:45 +00:00
return promisify('onDisconnectSet', FirebaseDatabase)(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 {*}
*/
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);
}
}