0.1.1 • Published 9 years ago
ampfire-model v0.1.1
AmpFire-Model
A modified, CommonJS version of Firebase's BackboneFire for AmpersandJS Models.
Installation
npm install ampfire-model
If you want it automatically added to your project's package.json use:
npm install ampfire-model --save
Basic Usage
First you should require the module.
var AmpfireModel = require('./ampfire-model');
Next simply extend the AmpfireModel passing it the firebase url
var RealtimeModel = AmpfireModel.extend({
url: 'https://example-db.firebaseio.com/todos',
autoSync: true // true by default
});
// Instantiate the model
var realtimeModel = new RealtimeModel();
realtimeModel.on('sync', function(model) {
console.log('model loaded', model);
});
The rest of the API is the same as that of BackboneFire
Dependencies
- ampersand-model
- lodash functions
- extend: lodash.object
- keys: lodash.object
- defaults: lodash.object
- result: lodash.object
- isObject: lodash.lang
- isFunction: lodash.lang
- difference: lodash/array/difference
- bind: lodash/function/bind
- each: lodash/collection/eac
Tests
Coming soon...
Demo
Coming soon...
Credits
This is all just a modification of the amazing work the Firebase team did on BackboneFire. It uses the awesome AmpersandJS Framework from the guys over at &yet.
Licence
MIT