Class: Fireproof

Fireproof

new Fireproof(firebaseRef)

Fireproofs an existing Firebase reference, giving it magic promise powers.

Parameters:
Name Type Description
firebaseRef Firebase

A Firebase reference object.

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.

Source:
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().

Source:
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.

Source:
Returns:

The total number of Firebase listeners presently operating.

Type
Number

<static> stats:getListeners() → {Object}

Gets data about listeners on Firebase locations.

Source:
Returns:

Listener counts keyed by Firebase path.

Type
Object

<static> stats:getPathCounts() → {Object}

Gets the per-operation, per-path counts of Firebase operations.

Source:
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.

Source:

<static> stats:resetListeners()

Resets the count of Firebase listeners back to 0.

Source:

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.

Source:
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>
Source:
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>
Source:
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>
Source:
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>
Source:
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>
Source:
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 and password.

onComplete function <optional>
options Object <optional>
Source:
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>
Source:

child(childPath) → {Fireproof}

Delegates Firebase#child, wrapping the child in fireproofing.

Parameters:
Name Type Description
childPath string

The subpath to refer to.

Source:
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>
Source:

endAt(priority, name) → {Fireproof}

Delegates Firebase#endAt.

Parameters:
Name Type Description
priority object
name string
Source:
Returns:
Type
Fireproof

equalTo(priority, name) → {Fireproof}

Delegates Firebase#equalTo.

Parameters:
Name Type Description
priority object
name string
Source:
Returns:
Type
Fireproof

getAuth() → {Object}

Delegates Firebase#getAuth.

Source:
Returns:

user info object, or null otherwise.

Type
Object

limit(limit) → {Fireproof}

Delegates Firebase#limit.

Parameters:
Name Type Description
limit Number
Source:
Returns:
Type
Fireproof

name() → {string}

Delegates Firebase#name.

Source:
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>
Source:

offAuth(onComplete, context)

Delegates Firebase#offAuth.

Parameters:
Name Type Argument Description
onComplete function

The function previously passed to onAuth.

context Object <optional>
Source:

on(eventType, callback, cancelCallback, context) → {function}

Delegates Firebase#on.

Parameters:
Name Type Argument Description
eventType string
callback function
cancelCallback function <optional>
context object <optional>
Source:
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>
Source:

once(eventType, successCallback, failureCallback, context) → {Promise}

Delegates Firebase#once.

Parameters:
Name Type Argument Description
eventType object
successCallback function
failureCallback function <optional>
context object <optional>
Source:
Returns:

Resolves on success and rejects on failure.

Type
Promise

parent() → {Fireproof}

Delegates Firebase#parent.

Source:
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.

Source:
Returns:

Resolves on success, rejects on failure.

Type
Promise

ref() → {Fireproof}

Delegates Firebase#ref.

Source:
Returns:
Type
Fireproof

remove(onComplete) → {Promise}

Delegates Firebase#remove.

Parameters:
Name Type Argument Description
onComplete function <optional>

Callback when the operation is done.

Source:
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>
Source:

resetPassword(credentials, onComplete)

Delegates Firebase#resetPassword.

Parameters:
Name Type Argument Description
credentials Object
onComplete function <optional>
Source:

root() → {Fireproof}

Delegates Firebase#root.

Source:
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.

Source:
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.

Source:
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.

Source:
Returns:

Resolves on success, rejects on failure.

Type
Promise

startAt(priority, name) → {Fireproof}

Delegates Firebase#startAt.

Parameters:
Name Type Description
priority object
name string
Source:
Returns:
Type
Fireproof

toFirebase() → {Firebase}

Hands back the original Firebase reference.

Source:
Returns:

The proxied Firebase reference.

Type
Firebase

toString() → {string}

Delegates Firebase#toString.

Source:
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>
Source:
Returns:

Resolves on success, rejects on failure.

Type
Promise

unauth()

Delegates Firebase#unauth.

Source:

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.

Source:
Returns:

Resolves on success, rejects on failure.

Type
Promise