Home Reference Source
import {FirebaseDataSource} from 'arva-js/data/datasources/FirebaseDataSource.js'
public class | source

FirebaseDataSource

Extends:

DataSource → FirebaseDataSource

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get
public set
public
public

options: *

Method Summary

Public Methods
public

authAnonymously(onComplete: Function, options: Object): Promise

Authenticates all instances of this DataSource as an anonymous user.

public

authWithCustomToken(authToken: String, onComplete: Function): Promise

Authenticates all instances of this DataSource with a custom auth token or secret.

public

authWithOAuthToken(provider: String, credentials: String | Object, onComplete: Function): Promise

Authenticates all instances of this DataSource with the given OAuth provider and credentials.

public

authWithPassword(credentials: String | Object, onComplete: Function): Promise

Authenticates all instances of this DataSource with the given email/password credentials.

public

child(childName: String, options: Object): DataSource

Returns a dataSource reference to the given child branch of the current datasource.

public

Fetches the current user's authentication state. If the user is authenticated, returns an object containing at least the fields uid, provider, auth, and expires. If the user is not authenticated, returns null.

public

key(): String

Returns the name of the current branch in the path on the dataSource.

public

Returns a new dataSource reference that will limit the subscription to only the first given amount items.

public

Returns a new dataSource reference that will limit the subscription to only the last given amount items.

public

off(event: String, handler: Function): void

Unsubscribe to a previously subscribed event.

public

on(event: String, handler: Function, context: Object): void

Subscribe to an event emitted by the DataSource.

public

once(event: String, handler: Function, context: Object): void

Subscribe to an event emitted by the DataSource once, and then immediately unsubscribe again once it has been emitted a single time.

public

Orders the DataSource's childs by the value in child[key].

public

Orders the DataSource's childs by their key names, ignoring their priority.

public

Orders the DataSource's childs by their values, ignoring their priority.

public

Returns the full URL to the parent of the current branch on the dataSource.

public

Returns the full URL to the path on the dataSource.

public

Writes newData to the path this dataSource was constructed with, appended by a random UID generated by the dataSource.

public

remove(): void

Removes the object and all underlying children that this dataSource points to.

public
this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource adds a data element.

public
this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource changes a data element.

public
this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource moves a data element.

public
this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource removes a data element.

public
this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource updates the data.

public

Returns the full URL to the root on the dataSource.

public

set(newData: Object): Promise

Writes newData to the path this dataSource was constructed with.

public

setChildAddedCallback(callback: Function): void

this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource adds a data element.

public
this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource changes a data element.

public

setChildMovedCallback(callback: Function): void

this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource moves a data element.

public
this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource removes a data element.

public

setPriority(newPriority: String | Number): void

Sets the priority (ordering) of an object on a given dataSource.

public
this method was deprecated. Use the on() method instead.

Sets the callback triggered when dataSource updates the data.

public

setWithPriority(newData: Object, priority: String | Number): Promise

Writes newData with given priority (ordering) to the path this dataSource was constructed with.

public

Resolves when the DataSource is synchronized to the server

public

Returns the full path to this dataSource's source on the remote storage provider.

public

unauth(): void

Logs out from the datasource, allowing to re-authenticate at a later time.

Inherited Summary

From class DataSource
public get

Indicate that the DataSource can be inherited when instantiating a list of models.

public

authAnonymously(onComplete: Function, options: Object): void

Authenticates all instances of this DataSource as an anonymous user.

public

authWithCustomToken(authToken: String, onComplete: Function, options: Object): void

Authenticates all instances of this DataSource with a custom auth token or secret.

public

authWithOAuthToken(provider: String, credentials: String | Object, onComplete: Function, options: Object): void

Authenticates all instances of this DataSource with the given OAuth provider and credentials.

public

authWithPassword(credentials: String | Object, onComplete: Function, options: Object): void

Authenticates all instances of this DataSource with the given email/password credentials.

public

child(childName: String, options: Object): DataSource

Returns a dataSource reference to the given child branch of the current dataSource.

public

Fetches the current user's authentication state. If the user is authenticated, returns an object containing at least the fields uid, provider, auth, and expires. If the user is not authenticated, returns null.

public

key(): String

Returns the name of the current branch in the path on the dataSource.

public

Returns a new dataSource reference that will limit the subscription to only the first given amount items.

public

Returns a new dataSource reference that will limit the subscription to only the last given amount items.

public

off(event: String, handler: Function)

Unsubscribe to a previously subscribed event.

public

on(event: String, handler: Function, context: Object)

Subscribe to an event emitted by the DataSource.

public

once(event: String, handler: Function, context: Object)

Subscribe to an event emitted by the DataSource once, and then immediately unsubscribe.

public

Orders the DataSource's childs by the value in child[key].

public

Orders the DataSource's childs by their key names, ignoring their priority.

public

Orders the DataSource's childs by their values, ignoring their priority.

public

Returns the full URL to the path on the dataSource.

public

push(newData: Object): void

Writes newData to the path this dataSource was constructed with, appended by a random UID generated by the dataSource.

public

remove(): void

Removes the object and all underlying children that this dataSource points to.

public

Removes the callback set to trigger when dataSource adds a data element.

public

Removes the callback set to trigger when dataSource changes a data element.

public

Removes the callback set to trigger when dataSource moves a data element.

public

Removes the callback set to trigger when dataSource removes a data element.

public

Removes the callback set to trigger when dataSource updates the data.

public

set(newData: Object): Promise

Writes newData to the path this dataSource was constructed with.

public

setChildAddedCallback(callback: Function): void

Set the callback triggered when dataSource adds a data element.

public

Set the callback triggered when dataSource changes a data element.

public

setChildMovedCallback(callback: Function): void

Set the callback triggered when dataSource moves a data element.

public

Set the callback triggered when dataSource removes a data element.

public

setPriority(newPriority: String | Number): void

Sets the priority (ordering) of an object on a given dataSource.

public

Sets the callback triggered when dataSource updates the data.

public

setWithPriority(newData: Object, priority: String | Number): Promise

Writes newData with given priority (ordering) to the path this dataSource was constructed with.

public

Resolves when the DataSource is synchronized to the server

public

Returns the full path to this dataSource's source on the remote storage provider.

public

unauth(): void

Logs out from the datasource, allowing to re-authenticate at a later time.

Public Constructors

public constructor(path: String, options: Object): FirebaseDataSource source

Override:

DataSource#constructor

Params:

NameTypeAttributeDescription
path String

Full path to resource in remote data storage.

options Object

Optional: options to construct the DataSource with.

options.orderBy String
  • optional

Optional, order all items received through the dataSource. Options are: '.priority', '.value', or a string containing the child key to order by (e.g. 'MyModelProperty')

options.limitToFirst Number
  • optional

Optional, only subscribe to the first amount of entries.

options.limitToLast Number
  • optional

Optional, only subscribe to the last amount of entries.

options.synced Promise
  • optional

Optional, a promise to tell the data source that it is only synchronized after this promise is resolved

Return:

FirebaseDataSource

FirebaseDataSource instance.

Public Members

public get dataReference: * source

public set dataReference: * source

public handlers: * source

public options: * source

Public Methods

public authAnonymously(onComplete: Function, options: Object): Promise source

Authenticates all instances of this DataSource as an anonymous user.

Override:

DataSource#authAnonymously

Params:

NameTypeAttributeDescription
onComplete Function

Callback, executed when login is completed either successfully or erroneously. On error, first argument is error message. On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.

options Object

Optional, additional client arguments, such as configuring session persistence.

Return:

Promise

A promise that resolves after successful authentication.

public authWithCustomToken(authToken: String, onComplete: Function): Promise source

Authenticates all instances of this DataSource with a custom auth token or secret.

Override:

DataSource#authWithCustomToken

Params:

NameTypeAttributeDescription
authToken String

Authentication token or secret.

onComplete Function

Callback, executed when login is completed either successfully or erroneously. On error, first argument is error message. On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.

Return:

Promise

A promise that resolves after successful authentication.

public authWithOAuthToken(provider: String, credentials: String | Object, onComplete: Function): Promise source

Authenticates all instances of this DataSource with the given OAuth provider and credentials.

Override:

DataSource#authWithOAuthToken

Params:

NameTypeAttributeDescription
provider String

google, facebook, github, or twitter

credentials String | Object

Access token string, or object with key/value pairs with e.g. OAuth 1.1 credentials.

onComplete Function

Callback, executed when login is completed either successfully or erroneously. On error, first argument is error message. On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.

Return:

Promise

A promise that resolves after successful authentication.

public authWithPassword(credentials: String | Object, onComplete: Function): Promise source

Authenticates all instances of this DataSource with the given email/password credentials.

Override:

DataSource#authWithPassword

Params:

NameTypeAttributeDescription
credentials String | Object

Object with key/value pairs {email: "value", password:"value"}.

onComplete Function

Callback, executed when login is completed either successfully or erroneously. On error, first argument is error message. On success, the first argument is null, and the second argument is an object containing the fields uid, provider, auth, and expires.

Return:

Promise

A promise that resolves after successful authentication.

public child(childName: String, options: Object): DataSource source

Returns a dataSource reference to the given child branch of the current datasource.

Override:

DataSource#child

Params:

NameTypeAttributeDescription
childName String

Child branch name.

options Object

Optional: additional options to pass to new DataSource instance.

Return:

DataSource

New dataSource instance pointing to the given child branch.

public getAuth(): Object | null source

Fetches the current user's authentication state. If the user is authenticated, returns an object containing at least the fields uid, provider, auth, and expires. If the user is not authenticated, returns null.

Override:

DataSource#getAuth

Return:

Object | null

User auth object.

public key(): String source

Returns the name of the current branch in the path on the dataSource.

Override:

DataSource#key

Return:

String

Current branch name.

public limitToFirst(amount: Number): DataSource source

Returns a new dataSource reference that will limit the subscription to only the first given amount items.

Override:

DataSource#limitToFirst

Params:

NameTypeAttributeDescription
amount Number

Amount of items to limit the dataSource to.

Return:

DataSource

New dataSource instance.

public limitToLast(amount: Number): DataSource source

Returns a new dataSource reference that will limit the subscription to only the last given amount items.

Override:

DataSource#limitToLast

Params:

NameTypeAttributeDescription
amount Number

Amount of items to limit the dataSource to.

Return:

DataSource

New dataSource instance.

public off(event: String, handler: Function): void source

Unsubscribe to a previously subscribed event. If no handler or context is given, all handlers for the given event are removed. If no parameters are given at all, all event types will have their handlers removed.

Override:

DataSource#off

Params:

NameTypeAttributeDescription
event String

Event type to unsubscribe from. Allowed values are: 'value', 'child_changed', 'child_added', 'child_removed', 'child_moved'.

handler Function

Optional: Function that was used in previous subscription.

Return:

void

public on(event: String, handler: Function, context: Object): void source

Subscribe to an event emitted by the DataSource.

Override:

DataSource#on

Params:

NameTypeAttributeDescription
event String

Event type to subscribe to. Allowed values are: 'value', 'child_changed', 'child_added', 'child_removed', 'child_moved'.

handler Function

Function to call when the subscribed event is emitted.

context Object

Context to set 'this' to when calling the handler function.

Return:

void

public once(event: String, handler: Function, context: Object): void source

Subscribe to an event emitted by the DataSource once, and then immediately unsubscribe again once it has been emitted a single time.

Override:

DataSource#once

Params:

NameTypeAttributeDescription
event String

Event type to subscribe to. Allowed values are: 'value', 'child_changed', 'child_added', 'child_removed', 'child_moved'.

handler Function

Function to call when the subscribed event is emitted.

context Object

Context to set 'this' to when calling the handler function.

Return:

void

public orderByChild(childKey: String): DataSource source

Orders the DataSource's childs by the value in child[key].

Override:

DataSource#orderByChild

Params:

NameTypeAttributeDescription
childKey String

Key of the field to order by.

Return:

DataSource

New dataSource instance.

public orderByKey(): DataSource source

Orders the DataSource's childs by their key names, ignoring their priority.

Override:

DataSource#orderByKey

Return:

DataSource

New dataSource instance.

public orderByValue(): DataSource source

Orders the DataSource's childs by their values, ignoring their priority.

Override:

DataSource#orderByValue

Return:

DataSource

New dataSource instance.

public parent(): String source

Returns the full URL to the parent of the current branch on the dataSource.

Return:

String

Full resource path of parent.

public path(): String source

Returns the full URL to the path on the dataSource. Functionally identical to toString().

Override:

DataSource#path

Return:

String

Full resource path.

public push(newData: Object): FirebaseDataSource source

Writes newData to the path this dataSource was constructed with, appended by a random UID generated by the dataSource.

Override:

DataSource#push

Params:

NameTypeAttributeDescription
newData Object

New data to append to dataSource.

Return:

FirebaseDataSource

A new FirebaseDataSource pointing to the injected data.

public remove(): void source

Removes the object and all underlying children that this dataSource points to.

Override:

DataSource#remove

Return:

void

public removeChildAddedCallback(): void source

this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource adds a data element.

Override:

DataSource#removeChildAddedCallback

Return:

void

public removeChildChangedCallback(): void source

this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource changes a data element.

Override:

DataSource#removeChildChangedCallback

Return:

void

public removeChildMovedCallback(): void source

this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource moves a data element.

Override:

DataSource#removeChildMovedCallback

Return:

void

public removeChildRemovedCallback(): void source

this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource removes a data element.

Override:

DataSource#removeChildRemovedCallback

Return:

void

public removeValueChangedCallback(): void source

this method was deprecated. Use the off() method instead.

Removes the callback set to trigger when dataSource updates the data.

Override:

DataSource#removeValueChangedCallback

Return:

void

public root(): String source

Returns the full URL to the root on the dataSource.

Return:

String

Full resource path of root.

public set(newData: Object): Promise source

Writes newData to the path this dataSource was constructed with.

Override:

DataSource#set

Params:

NameTypeAttributeDescription
newData Object

Data to write to dataSource.

Return:

Promise

Resolves when write to server is complete.

public setChildAddedCallback(callback: Function): void source

this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource adds a data element.

Override:

DataSource#setChildAddedCallback

Params:

NameTypeAttributeDescription
callback Function

Callback function to call when a new data child is added.

Return:

void

public setChildChangedCallback(callback: Function): void source

this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource changes a data element.

Override:

DataSource#setChildChangedCallback

Params:

NameTypeAttributeDescription
callback Function

Callback function to call when a child is changed.

Return:

void

public setChildMovedCallback(callback: Function): void source

this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource moves a data element.

Override:

DataSource#setChildMovedCallback

Params:

NameTypeAttributeDescription
callback Function

Callback function to call when a child is moved.

Return:

void

public setChildRemovedCallback(callback: Function): void source

this method was deprecated. Use the on() method instead.

Set the callback triggered when dataSource removes a data element.

Override:

DataSource#setChildRemovedCallback

Params:

NameTypeAttributeDescription
callback Function

Callback function to call when a child is removed.

Return:

void

public setPriority(newPriority: String | Number): void source

Sets the priority (ordering) of an object on a given dataSource.

Override:

DataSource#setPriority

Params:

NameTypeAttributeDescription
newPriority String | Number

New priority value to order data by.

Return:

void

public setValueChangedCallback(callback: Function): void source

this method was deprecated. Use the on() method instead.

Sets the callback triggered when dataSource updates the data.

Override:

DataSource#setValueChangedCallback

Params:

NameTypeAttributeDescription
callback Function

Callback function to call when the subscribed data value changes.

Return:

void

public setWithPriority(newData: Object, priority: String | Number): Promise source

Writes newData with given priority (ordering) to the path this dataSource was constructed with.

Override:

DataSource#setWithPriority

Params:

NameTypeAttributeDescription
newData Object

New data to set.

priority String | Number

Priority value by which the data should be ordered.

Return:

Promise

Resolves when write to server is complete.

public synced(): Promise source

Resolves when the DataSource is synchronized to the server

Override:

DataSource#synced

Return:

Promise

Resolves when the DataSource is synchronized

public toString(): String source

Returns the full path to this dataSource's source on the remote storage provider.

Override:

DataSource#toString

Return:

String

Full resource path.

public unauth(): void source

Logs out from the datasource, allowing to re-authenticate at a later time.

Override:

DataSource#unauth

Return:

void