3.1.0 • Published 8 years ago

fireproof v3.1.0

Weekly downloads
68
License
ISC
Repository
github
Last release
8 years ago

fireproof

Firebase runs hot! Don't burn yourself with callbacks. Use promises instead. Fireproof wraps Firebase objects with lightweight promise support.

Installation

npm install --save fireproof

Usage

See the API documentation here.

The bottom line is this: all Firebase methods are reproduced on a Fireproof object.

By default, Fireproof uses the built-in Promise constructor, which is available in Node > 0.12 and many modern web browsers. You can override this behavior by providing a standards-compliant Promise constructor on Fireproof's constructor, like so:

Fireproof.Promise = require('bluebird');

You can also choose to "bless" Fireproof with a promise library that follows the deferral model:

Fireproof.bless(require('Q'));

If a Promise constructor is not supplied and none exists natively, Fireproof will explode spectacularly.

  • If the corresponding Firebase method has no return value but does something asynchronously, Fireproof returns a promise that fulfills if the interaction succeeds and rejects if an error occurs. This is true of, e.g., transaction(), auth(), set(), update(), remove(), and once().

  • For on(), Firebase returns the callback method that you passed in. Fireproof returns your wrapped callback method with an extra method, then(), attached. So the callback is effectively a promise!

  • For push(), Firebase returns the reference to the new child. Fireproof does the same, but the reference is also a promise that resolves if the push succeeds and rejects if the push fails.

  • All Fireproof objects are themselves promises. Except for the case of push() mentioned above, their then() is a shortcut for fp.once('value'). This means you can get the value of any Fireproof object at any time just by treating it as a promise!

var Fireproof = require('fireproof'),
  Firebase = require('firebase');

var firebase = new Firebase('https://test.firebaseio.com/thing'),
  fireproof = new Fireproof(firebase);

fireproof.auth('my_auth_token').then(function() {
  console.log('Successfully authenticated.')
}, function(err) {
  console.error('Error authenticating to Firebase!');
})

Support

IE back to 9.

3.1.0

8 years ago

3.0.4

8 years ago

3.0.3

9 years ago

3.0.2

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.5.3

9 years ago

2.5.2

9 years ago

2.5.1

9 years ago

2.5.0

9 years ago

2.4.3

9 years ago

2.4.2

9 years ago

2.4.1

9 years ago

2.4.0

9 years ago

2.3.2

9 years ago

2.3.1

9 years ago

2.3.0

9 years ago

2.2.2

9 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.6

9 years ago

1.15.3

9 years ago

1.15.2

9 years ago

1.15.1

9 years ago

1.15.0

9 years ago

1.14.2

9 years ago

1.14.1

9 years ago

1.14.0

9 years ago

1.12.0

9 years ago

1.11.0

9 years ago

1.10.0

9 years ago

1.9.3

9 years ago

1.9.2

9 years ago

2.0.0

10 years ago

1.9.1

10 years ago

1.9.0

10 years ago

1.8.0

10 years ago

1.7.3

10 years ago

1.7.0

10 years ago

1.6.8

10 years ago

1.6.5

10 years ago

1.6.4

10 years ago

1.6.3

10 years ago

1.6.2

10 years ago

1.6.1

10 years ago

1.6.0

10 years ago

1.5.0

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.0

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago