new Fireproof(firebaseRef)
Fireproofs an existing Firebase reference, giving it magic promise powers.
Parameters:
Name | Type | Description |
---|---|---|
firebaseRef |
Firebase | A Firebase reference object. |
- Source:
Properties:
Name | Type | Description |
---|---|---|
then |
A promise shortcut for .once('value'), except for references created by .push(), where it resolves on success and rejects on failure of the property object. |
Example
var fp = new Fireproof(new Firebase('https://test.firebaseio.com/something')); fp.then(function(snap) { console.log(snap.val()); });
Methods
-
<static> bless(Q)
-
Tell Fireproof to use a given promise library from now on.
Parameters:
Name Type Description Q
Q a Q-style promise constructor with at least defer().
Throws:
if you don't provide a valid Deferred-style promise library. -
<static> stats:getListenerCount() → {Number}
-
Gets the total number of listeners on Firebase locations.
Returns:
The total number of Firebase listeners presently operating.
- Type
- Number
-
<static> stats:getListeners() → {Object}
-
Gets data about listeners on Firebase locations.
Returns:
Listener counts keyed by Firebase path.
- Type
- Object
-
<static> stats:getPathCounts() → {Object}
-
Gets the per-operation, per-path counts of Firebase operations.
Returns:
An object with three keys: "read", "write", and "update". Each key has an object value, of which the keys are Firebase paths and the values are counts.
- Type
- Object
-
<static> stats:reset()
-
Resets the count of Firebase operations back to 0.
-
<static> stats:resetListeners()
-
Resets the count of Firebase listeners back to 0.
-
auth(authToken, onComplete, onCancel) → {Promise}
-
Delegates Firebase#auth.
Parameters:
Name Type Argument Description authToken
string Firebase authentication token.
onComplete
function <optional>
Callback on initial completion.
onCancel
function <optional>
Callback if we ever get disconnected.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
-
authAnonymously(onComplete, options) → {Promise}
-
Delegates Firebase#authAnonymously.
Parameters:
Name Type Argument Description onComplete
function <optional>
options
Object <optional>
Returns:
that resolves on auth success and rejects on auth failure.
- Type
- Promise
-
authWithCustomToken(authToken, onComplete, options) → {Promise}
-
Delegates Firebase#authWithCustomToken.
Parameters:
Name Type Argument Description authToken
String onComplete
function <optional>
options
Object <optional>
Returns:
that resolves on auth success and rejects on auth failure.
- Type
- Promise
-
authWithOAuthPopup(provider, onComplete, options) → {Promise}
-
Delegates Firebase#authWithOAuthPopup.
Parameters:
Name Type Argument Description provider
String onComplete
function <optional>
options
Object <optional>
Returns:
that resolves on auth success and rejects on auth failure.
- Type
- Promise
-
authWithOAuthPopup(provider, credentials, onComplete, options) → {Promise}
-
Delegates Firebase#authWithOAuthPopup.
Parameters:
Name Type Argument Description provider
String credentials
Object onComplete
function <optional>
options
Object <optional>
Returns:
that resolves on auth success and rejects on auth failure.
- Type
- Promise
-
authWithOAuthRedirect(provider, onComplete, options) → {Promise}
-
Delegates Firebase#authWithOAuthRedirect.
Parameters:
Name Type Argument Description provider
String onComplete
function <optional>
options
Object <optional>
Returns:
that resolves on auth success and rejects on auth failure.
- Type
- Promise
-
authWithPassword(credentials, onComplete, options) → {Promise}
-
Delegates Firebase#authWithPassword.
Parameters:
Name Type Argument Description credentials
Object Should include
email
andpassword
.onComplete
function <optional>
options
Object <optional>
Returns:
that resolves on auth success and rejects on auth failure.
- Type
- Promise
-
changePassword(credentials, onComplete)
-
Delegates Firebase#changePassword.
Parameters:
Name Type Argument Description credentials
Object onComplete
function <optional>
-
child(childPath) → {Fireproof}
-
Delegates Firebase#child, wrapping the child in fireproofing.
Parameters:
Name Type Description childPath
string The subpath to refer to.
Returns:
A reference to the child path.
- Type
- Fireproof
-
createUser(credentials, onComplete)
-
Delegates Firebase#createUser.
Parameters:
Name Type Argument Description credentials
Object onComplete
function <optional>
-
endAt(priority, name) → {Fireproof}
-
Delegates Firebase#endAt.
Parameters:
Name Type Description priority
object name
string Returns:
- Type
- Fireproof
-
equalTo(priority, name) → {Fireproof}
-
Delegates Firebase#equalTo.
Parameters:
Name Type Description priority
object name
string Returns:
- Type
- Fireproof
-
getAuth() → {Object}
-
Delegates Firebase#getAuth.
Returns:
user info object, or null otherwise.
- Type
- Object
-
limit(limit) → {Fireproof}
-
Delegates Firebase#limit.
Parameters:
Name Type Description limit
Number Returns:
- Type
- Fireproof
-
name() → {string}
-
Delegates Firebase#name.
Returns:
The last component of this reference object's path.
- Type
- string
-
off(eventType, callback, context)
-
Delegates Firebase#off.
Parameters:
Name Type Argument Description eventType
string callback
function <optional>
context
object <optional>
-
offAuth(onComplete, context)
-
Delegates Firebase#offAuth.
Parameters:
Name Type Argument Description onComplete
function The function previously passed to onAuth.
context
Object <optional>
-
on(eventType, callback, cancelCallback, context) → {function}
-
Delegates Firebase#on.
Parameters:
Name Type Argument Description eventType
string callback
function cancelCallback
function <optional>
context
object <optional>
Returns:
Your callback parameter wrapped in fireproofing. Use this return value, not your own copy of callback, to call .off(). It also functions as a promise that resolves on success and rejects on failure.
- Type
- function
-
onAuth(onComplete, context)
-
Delegates Firebase#onAuth.
Parameters:
Name Type Argument Description onComplete
function Gets called on auth change.
context
Object <optional>
-
once(eventType, successCallback, failureCallback, context) → {Promise}
-
Delegates Firebase#once.
Parameters:
Name Type Argument Description eventType
object successCallback
function failureCallback
function <optional>
context
object <optional>
Returns:
Resolves on success and rejects on failure.
- Type
- Promise
-
parent() → {Fireproof}
-
Delegates Firebase#parent.
Returns:
A ref to the parent path, or null if there is none.
- Type
- Fireproof
-
push(value, onComplete) → {Promise}
-
Delegates Firebase#push.
Parameters:
Name Type Argument Description value
object An object with keys and values to update.
onComplete
function <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
-
ref() → {Fireproof}
-
Delegates Firebase#ref.
Returns:
- Type
- Fireproof
-
remove(onComplete) → {Promise}
-
Delegates Firebase#remove.
Parameters:
Name Type Argument Description onComplete
function <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
-
removeUser(credentials, onComplete)
-
Delegates Firebase#removeUser.
Parameters:
Name Type Argument Description credentials
Object onComplete
function <optional>
-
resetPassword(credentials, onComplete)
-
Delegates Firebase#resetPassword.
Parameters:
Name Type Argument Description credentials
Object onComplete
function <optional>
-
root() → {Fireproof}
-
Delegates Firebase#root.
Returns:
A ref to the root.
- Type
- Fireproof
-
set(value, onComplete) → {Promise}
-
Delegates Firebase#set.
Parameters:
Name Type Argument Description value
object The value to set this path to.
onComplete
function <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
Example
fireproofRef.set('something') .then(function()) { console.log('set was successful!'); }, function(err) { console.error('error while setting:', err); });
-
setPriority(priority, onComplete) → {Promise}
-
Delegates Firebase#setPriority.
Parameters:
Name Type Argument Description priority
object The priority to set this path to.
onComplete
function <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
-
setWithPriority(value, priority, onComplete) → {Promise}
-
Delegates Firebase#setWithPriority.
Parameters:
Name Type Argument Description value
object The value to set this path to.
priority
object The priority to set this path to.
onComplete
function <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
-
startAt(priority, name) → {Fireproof}
-
Delegates Firebase#startAt.
Parameters:
Name Type Description priority
object name
string Returns:
- Type
- Fireproof
-
toFirebase() → {Firebase}
-
Hands back the original Firebase reference.
Returns:
The proxied Firebase reference.
- Type
- Firebase
-
toString() → {string}
-
Delegates Firebase#toString.
Returns:
The full URL of this reference object.
- Type
- string
-
transaction(updateFunction, onComplete, applyLocally) → {Promise}
-
Delegates Firebase#transaction.
Parameters:
Name Type Argument Description updateFunction
function onComplete
function applyLocally
boolean <optional>
Returns:
Resolves on success, rejects on failure.
- Type
- Promise
-
unauth()
-
Delegates Firebase#unauth.
-
update(value, onComplete) → {Promise}
-
Delegates Firebase#update.
Parameters:
Name Type Argument Description value
object An object with keys and values to update.
onComplete
function <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise