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 QQ 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 authTokenstring Firebase authentication token.
onCompletefunction <optional>
Callback on initial completion.
onCancelfunction <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 onCompletefunction <optional>
optionsObject <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 authTokenString onCompletefunction <optional>
optionsObject <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 providerString onCompletefunction <optional>
optionsObject <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 providerString credentialsObject onCompletefunction <optional>
optionsObject <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 providerString onCompletefunction <optional>
optionsObject <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 credentialsObject Should include
emailandpassword.onCompletefunction <optional>
optionsObject <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 credentialsObject onCompletefunction <optional>
-
child(childPath) → {Fireproof}
-
Delegates Firebase#child, wrapping the child in fireproofing.
Parameters:
Name Type Description childPathstring 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 credentialsObject onCompletefunction <optional>
-
endAt(priority, name) → {Fireproof}
-
Delegates Firebase#endAt.
Parameters:
Name Type Description priorityobject namestring Returns:
- Type
- Fireproof
-
equalTo(priority, name) → {Fireproof}
-
Delegates Firebase#equalTo.
Parameters:
Name Type Description priorityobject namestring 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 limitNumber 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 eventTypestring callbackfunction <optional>
contextobject <optional>
-
offAuth(onComplete, context)
-
Delegates Firebase#offAuth.
Parameters:
Name Type Argument Description onCompletefunction The function previously passed to onAuth.
contextObject <optional>
-
on(eventType, callback, cancelCallback, context) → {function}
-
Delegates Firebase#on.
Parameters:
Name Type Argument Description eventTypestring callbackfunction cancelCallbackfunction <optional>
contextobject <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 onCompletefunction Gets called on auth change.
contextObject <optional>
-
once(eventType, successCallback, failureCallback, context) → {Promise}
-
Delegates Firebase#once.
Parameters:
Name Type Argument Description eventTypeobject successCallbackfunction failureCallbackfunction <optional>
contextobject <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 valueobject An object with keys and values to update.
onCompletefunction <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 onCompletefunction <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 credentialsObject onCompletefunction <optional>
-
resetPassword(credentials, onComplete)
-
Delegates Firebase#resetPassword.
Parameters:
Name Type Argument Description credentialsObject onCompletefunction <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 valueobject The value to set this path to.
onCompletefunction <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 priorityobject The priority to set this path to.
onCompletefunction <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 valueobject The value to set this path to.
priorityobject The priority to set this path to.
onCompletefunction <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 priorityobject namestring 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 updateFunctionfunction onCompletefunction applyLocallyboolean <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 valueobject An object with keys and values to update.
onCompletefunction <optional>
Callback when the operation is done.
Returns:
Resolves on success, rejects on failure.
- Type
- Promise