Kind: global class
Properties
| Name | 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. |
- Fireproof
- new Fireproof(firebaseRef)
- instance
- .child(childPath) ⇒
Fireproof - .parent() ⇒
Fireproof - .root() ⇒
Fireproof - .toFirebase() ⇒
Firebase - .name() ⇒
string - .key() ⇒
string - .toString() ⇒
string - ._wrapAuth(fn)
- .auth(authToken, [onComplete], [options]) ⇒
Promise - .authWithCustomToken(authToken, [onComplete], [options]) ⇒
Promise - .authAnonymously([onComplete], [options]) ⇒
Promise - .authWithPassword(credentials, [onComplete], [options]) ⇒
Promise - .authWithOAuthPopup(provider, [onComplete], [options]) ⇒
Promise - .authWithOAuthRedirect(provider, [onComplete], [options]) ⇒
Promise - .authWithOAuthPopup(provider, credentials, [onComplete], [options]) ⇒
Promise - .getAuth() ⇒
Object - .onAuth(onComplete, [context])
- .offAuth(onComplete, [context])
- .unauth()
- .onDisconnect() ⇒
Fireproof.OnDisconnect- .cancel([callback]) ⇒
Promise - .remove([callback]) ⇒
Promise - .set(value, [callback]) ⇒
Promise - .setWithPriority(value, priority, [callback]) ⇒
Promise - .update(value, [callback]) ⇒
Promise
- .cancel([callback]) ⇒
- .limit(limit) ⇒
Fireproof - .limitToFirst(limit) ⇒
Fireproof - .limitToLast(limit) ⇒
Fireproof - .orderByChild(key) ⇒
Fireproof - .orderByKey() ⇒
Fireproof - .orderByValue() ⇒
Fireproof - .orderByPriority() ⇒
Fireproof - .equalTo(value, [key]) ⇒
Fireproof - .startAt(value, [key]) ⇒
Fireproof - .endAt(value, [key]) ⇒
Fireproof - .ref() ⇒
Fireproof - .transaction(updateFunction, onComplete, [applyLocally]) ⇒
Promise - .on(eventType, callback, [cancelCallback], [context]) ⇒
function - .off(eventType, [callback], [context])
- .once(eventType, successCallback, [failureCallback], [context]) ⇒
Promise - .createUser(credentials, [onComplete]) ⇒
Promise - .changeEmail(credentials, [onComplete]) ⇒
Promise - .changePassword(credentials, [onComplete]) ⇒
Promise - .resetPassword(credentials, [onComplete]) ⇒
Promise - .createUser(credentials, [onComplete]) ⇒
Promise - .set(value, [onComplete]) ⇒
Promise - .update(value, [onComplete]) ⇒
Promise - .remove([onComplete]) ⇒
Promise - .push(value, [onComplete]) ⇒
Promise - .setWithPriority(value, priority, [onComplete]) ⇒
Promise - .setPriority(priority, [onComplete]) ⇒
Promise
- .child(childPath) ⇒
- static
- .Demux
- new Demux(refs, [limitToFirst])
- .get(count) ⇒
Promise
- .LiveArray
- .Pager
- new Pager(ref, [initialCount])
- .next(count) ⇒
Promise - .previous(count) ⇒
Promise
- .stats :
object- .reset()
- .getListeners() ⇒
Object - .getListenerCount() ⇒
Number - .getPathCounts() ⇒
Object - .getCounts() ⇒
Object - .on(name, fn) ⇒
function - .off([name], fn)
.bless(Deferrable)- .setNextTick(nextTick)
- .Demux
Fireproofs an existing Firebase reference, giving it magic promise powers.
| Param | Type | Description |
|---|---|---|
| firebaseRef | Firebase |
A Firebase reference object. |
Example
var fp = new Fireproof(new Firebase('https://test.firebaseio.com/something'));
fp.then(function(snap) { console.log(snap.val()); });fireproof.child(childPath) ⇒ Fireproof
Delegates Firebase#child, wrapping the child in fireproofing.
Kind: instance method of Fireproof
Returns: Fireproof - A reference to the child path.
| Param | Type | Description |
|---|---|---|
| childPath | string |
The subpath to refer to. |
fireproof.parent() ⇒ Fireproof
Delegates Firebase#parent, wrapping the child in fireproofing.
Kind: instance method of Fireproof
Returns: Fireproof - A ref to the parent path, or null if there is none.
fireproof.root() ⇒ Fireproof
Delegates Firebase#root, wrapping the root in fireproofing.
Kind: instance method of Fireproof
Returns: Fireproof - A ref to the root.
Hands back the original Firebase reference.
Kind: instance method of Fireproof
Returns: Firebase - The proxied Firebase reference.
Delegates Firebase#name.
Kind: instance method of Fireproof
Returns: string - The last component of this reference object's path.
Delegates Firebase#key.
Kind: instance method of Fireproof
Returns: string - The last component of this reference object's path.
Delegates Firebase#toString.
Kind: instance method of Fireproof
Returns: string - The full URL of this reference object.
Wraps auth methods so they execute in order.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| fn | function |
Auth function that generates a promise once it's done. |
Delegates Firebase#auth.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type |
|---|---|
| authToken | String |
| [onComplete] | function |
| [options] | Object |
Delegates Firebase#authWithCustomToken.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type |
|---|---|
| authToken | String |
| [onComplete] | function |
| [options] | Object |
Delegates Firebase#authAnonymously.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type |
|---|---|
| [onComplete] | function |
| [options] | Object |
Delegates Firebase#authWithPassword.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type | Description |
|---|---|---|
| credentials | Object |
Should include email and password. |
| [onComplete] | function |
|
| [options] | Object |
Delegates Firebase#authWithOAuthPopup.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type |
|---|---|
| provider | String |
| [onComplete] | function |
| [options] | Object |
Delegates Firebase#authWithOAuthRedirect.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type |
|---|---|
| provider | String |
| [onComplete] | function |
| [options] | Object |
Delegates Firebase#authWithOAuthPopup.
Kind: instance method of Fireproof
Returns: Promise - that resolves on auth success and rejects on auth failure.
| Param | Type |
|---|---|
| provider | String |
| credentials | Object |
| [onComplete] | function |
| [options] | Object |
Delegates Firebase#getAuth.
Kind: instance method of Fireproof
Returns: Object - user info object, or null otherwise.
Delegates Firebase#onAuth.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| onComplete | function |
Gets called on auth change. |
| [context] | Object |
Delegates Firebase#offAuth.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| onComplete | function |
The function previously passed to onAuth. |
| [context] | Object |
Delegates Firebase#unauth.
Kind: instance method of Fireproof
Delegates Fireproof#onDisconnect.
Kind: instance method of Fireproof
- .onDisconnect() ⇒
Fireproof.OnDisconnect- .cancel([callback]) ⇒
Promise - .remove([callback]) ⇒
Promise - .set(value, [callback]) ⇒
Promise - .setWithPriority(value, priority, [callback]) ⇒
Promise - .update(value, [callback]) ⇒
Promise
- .cancel([callback]) ⇒
Delegates onDisconnect()#cancel.
Kind: instance method of onDisconnect
| Param | Type | Description |
|---|---|---|
| [callback] | function |
Firebase callback. |
Delegates onDisconnect()#remove.
Kind: instance method of onDisconnect
| Param | Type | Description |
|---|---|---|
| [callback] | function |
Firebase callback. |
Delegates onDisconnect()#set.
Kind: instance method of onDisconnect
| Param | Type | Description |
|---|---|---|
| value | * |
Value to set on the ref on disconnect. |
| [callback] | function |
Firebase callback. |
Delegates onDisconnect()#setWithPriority.
Kind: instance method of onDisconnect
| Param | Type | Description |
|---|---|---|
| value | * |
Value to set on the ref on disconnect. |
| priority | * |
Priority to set on the ref on disconnect. |
| [callback] | function |
Firebase callback. |
Delegates onDisconnect()#update.
Kind: instance method of onDisconnect
| Param | Type | Description |
|---|---|---|
| value | * |
Value to update on the ref on disconnect. |
| [callback] | function |
Firebase callback. |
fireproof.limit(limit) ⇒ Fireproof
Delegates Firebase#limit.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| limit | Number |
fireproof.limitToFirst(limit) ⇒ Fireproof
Delegates Firebase#limitToFirst.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| limit | Number |
fireproof.limitToLast(limit) ⇒ Fireproof
Delegates Firebase#limitToLast.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| limit | Number |
fireproof.orderByChild(key) ⇒ Fireproof
Delegates Firebase#orderByChild.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| key | string |
fireproof.orderByKey() ⇒ Fireproof
Delegates Firebase#orderByKey.
Kind: instance method of Fireproof
fireproof.orderByValue() ⇒ Fireproof
Delegates Firebase#orderByValue.
Kind: instance method of Fireproof
fireproof.orderByPriority() ⇒ Fireproof
Delegates Firebase#orderByPriority.
Kind: instance method of Fireproof
fireproof.equalTo(value, [key]) ⇒ Fireproof
Delegates Firebase#equalTo.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| value | String | Number | null |
| [key] | String |
fireproof.startAt(value, [key]) ⇒ Fireproof
Delegates Firebase#startAt.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| value | object |
| [key] | string |
fireproof.endAt(value, [key]) ⇒ Fireproof
Delegates Firebase#endAt.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| value | object |
| [key] | string |
fireproof.ref() ⇒ Fireproof
Delegates Firebase#ref.
Kind: instance method of Fireproof
Delegates Firebase#transaction.
Kind: instance method of Fireproof
Returns: Promise - an Object with two properties: 'committed' and 'snapshot'.
| Param | Type |
|---|---|
| updateFunction | function |
| onComplete | function |
| [applyLocally] | boolean |
Delegates Firebase#on.
Kind: instance method of Fireproof
Returns: function - 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 with a {FireproofSnapshot}.
| Param | Type | Description |
|---|---|---|
| eventType | string |
'value', 'child_added', 'child_changed', 'child_moved', or 'child_removed' |
| callback | function |
|
| [cancelCallback] | function |
|
| [context] | object |
Delegates Firebase#off.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| eventType | string |
| [callback] | function |
| [context] | object |
Delegates Firebase#once.
Kind: instance method of Fireproof
Returns: Promise - Resolves with {FireproofSnapshot}.
| Param | Type | Description |
|---|---|---|
| eventType | object |
'value', 'child_added', 'child_changed', 'child_moved', or 'child_removed' |
| successCallback | function |
|
| [failureCallback] | function |
|
| [context] | object |
Delegates Firebase#createUser.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| credentials | Object |
| [onComplete] | function |
Delegates Firebase#changeEmail.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| credentials | Object |
| [onComplete] | function |
Delegates Firebase#changePassword.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| credentials | Object |
| [onComplete] | function |
Delegates Firebase#resetPassword.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| credentials | Object |
| [onComplete] | function |
Delegates Firebase#removeUser.
Kind: instance method of Fireproof
| Param | Type |
|---|---|
| credentials | Object |
| [onComplete] | function |
Delegates Firebase#set.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| value | object |
The value to set this path to. |
| [onComplete] | function |
Callback when the operation is done. |
Example
fireproofRef.set('something')
.then(function()) {
console.log('set was successful!');
}, function(err) {
console.error('error while setting:', err);
});Delegates Firebase#update.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| value | object |
An object with keys and values to update. |
| [onComplete] | function |
Callback when the operation is done. |
Delegates Firebase#remove.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| [onComplete] | function |
Callback when the operation is done. |
Delegates Firebase#push.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| value | object |
An object with keys and values to update. |
| [onComplete] | function |
Callback when the operation is done. |
Delegates Firebase#setWithPriority.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| value | object |
The value to set this path to. |
| priority | object |
The priority to set this path to. |
| [onComplete] | function |
Callback when the operation is done. |
Delegates Firebase#setPriority.
Kind: instance method of Fireproof
| Param | Type | Description |
|---|---|---|
| priority | object |
The priority to set this path to. |
| [onComplete] | function |
Callback when the operation is done. |
Kind: static class of Fireproof
- .Demux
- new Demux(refs, [limitToFirst])
- .get(count) ⇒
Promise
A helper object for retrieving sorted Firebase objects from multiple locations.
| Param | Type | Description |
|---|---|---|
| refs | Array |
a list of Fireproof object references to draw from. |
| [limitToFirst] | boolean |
Whether to use "limitToFirst" to restrict the length of queries to Firebase. True by default. Set this to false if you want to control the query more directly by setting it on the objects you pass to refs. |
Get the next count items from the paths, ordered by priority.
Kind: instance method of Demux
Returns: Promise - A promise that resolves with the next count items, ordered by priority.
| Param | Type | Description |
|---|---|---|
| count | Number |
The number of items to get from the list. |
Kind: static class of Fireproof
Properties
| Name | Type | Description |
|---|---|---|
| keys | Array |
A live array of the keys at the Firebase ref. |
| values | Array |
A live array of the values at the Firebase ref. |
| priorities | Array |
A live array of the priorities at the Firebase ref. |
A live array that keeps its members in sync with a Firebase location's children.
The three array references, keys, values, and priorities, are guaranteed
to persist for the lifetime of the array. In other words, the arrays themselves
are constant; only their contents are mutable. This is highly useful behavior
for dirty-checking environments like Angular.js.
| Param | Type | Description |
|---|---|---|
| [errorHandler] | function |
a function to be called if a Firebase error occurs. |
Connect this LiveArray to a Firebase reference, instantiating listeners for child events. If an error is received from a Firebase listener, all listeners are disconnected, LiveArray#error is set, and your error handler is called if you supplied one.
Kind: instance method of LiveArray
| Param | Type | Description |
|---|---|---|
| [ref] | Fireproof |
a Firebase ref whose children you wish to sync to. |
| [sortMode] | String |
"key", "priority", or "child". |
| [sortProperty] | String |
The name of the child property to sort on, if sortMode is "child". |
Disconnect this LiveArray from a Firebase reference, removing all listeners. Also clears the contents of the live array references.
Kind: instance method of LiveArray
Kind: static class of Fireproof
Properties
| Name | Type | Description |
|---|---|---|
| hasPrevious | Boolean |
True if there are more objects before the current page. |
| hasNext | Boolean |
True if there are more objects after the current page. |
- .Pager
- new Pager(ref, [initialCount])
- .next(count) ⇒
Promise - .previous(count) ⇒
Promise
A helper object for paging over Firebase objects.
| Param | Type | Description |
|---|---|---|
| ref | Fireproof |
a Firebase ref whose children you wish to page over. |
| [initialCount] | Number |
The number of objects in the first page. |
Get the next page of children from the ref.
Kind: instance method of Pager
Returns: Promise - A promise that resolves with an array of the next children.
| Param | Type | Description |
|---|---|---|
| count | Number |
The size of the page. |
Get the previous page of children from the ref.
Kind: instance method of Pager
Returns: Promise - A promise that resolves with an array of the next children.
| Param | Type | Description |
|---|---|---|
| count | Number |
The size of the page. |
Statistics about Firebase usage.
Kind: static namespace of Fireproof
Properties
| Name | Type |
|---|---|
| operationLog | Object |
| runningOperationCount | Number |
| operationCount | Number |
| listenCount | Number |
- .stats :
object- .reset()
- .getListeners() ⇒
Object - .getListenerCount() ⇒
Number - .getPathCounts() ⇒
Object - .getCounts() ⇒
Object - .on(name, fn) ⇒
function - .off([name], fn)
Resets the count of Firebase operations back to 0.
Kind: static method of stats
Gets data about listeners on Firebase locations.
Kind: static method of stats
Returns: Object - Listener counts keyed by Firebase path.
Gets the total number of listeners on Firebase locations.
Kind: static method of stats
Returns: Number - The total number of Firebase listeners presently operating.
Gets the per-operation, per-path counts of Firebase operations.
Kind: static method of stats
Returns: Object - An object with keys like "listen", "readOnce", "write",
and "update". Each key has an object value, of which the keys are Firebase
paths and the values are counts.
Gets the per-operation counts of Firebase operations.
Kind: static method of stats
Returns: Object - An object with with keys like "read", "write",
and "update". The values are the counts of operations under those headings.
Listens for Firebase events occurring.
Kind: static method of stats
Returns: function - fn is returned for convenience, to pass to off.
Throws:
- if you don't pass in a function for fn.
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the event. One of 'start', 'finish', 'error', 'listenStarted', or 'listenEnded.' |
| fn | function |
The function to call when the event happens. Takes a single parameter, the event object. |
Stops sending events to a listener.
Kind: static method of stats
Throws:
- if you don't pass in a function for fn.
| Param | Type | Description |
|---|---|---|
| [name] | String |
The name of the event. One of 'start', 'finish', 'error', 'listenStarted', or 'listenEnded.' |
| fn | function |
The function to stop calling. |
Deprecated
Tell Fireproof to use a given defer-style promise library from now on. If you have native promises, you don't need to call this; if you want to substitute a different promise constructor, just set it on Fireproof.Promise directly.
Kind: static method of Fireproof
Throws:
- if you don't provide a valid promise library.
| Param | Type | Description |
|---|---|---|
| Deferrable | function |
a deferrable promise constructor with .all(). |
Tell Fireproof to use a given function to set timeouts from now on.
Kind: static method of Fireproof
| Param | Type | Description |
|---|---|---|
| nextTick | function |
a function that takes a function and runs it in the immediate future. |