var db = new PouchDB('dbname');
db.put({
_id: 'dave@gmail.com',
name: 'David',
age: 67
});
db.changes().on('change', function() {
console.log('Ch-Ch-Changes');
});
db.replicate.to('http://example.com/mydb');
//CREATE A FIREBASE
var fb = new Firebase("https://YOUR.firebaseio.com/");
//SAVE DATA
fb.set({ name: "Alex Wolfe" });
//LISTEN FOR REALTIME CHANGES
fb.on("value", function(data) {
var name = data.val() ? data.val().name : "";
alert("My name is " + name);
});
diff
log
hoodie = new Hoodie();
hoodie.store.findAll().done(function(pets) {
$scope.pets = pets;
});
hoodie.store.on('change', function (eventName, changedObject) {
$scope.$apply(refresh);
});
$scope.addPet = function() {
hoodie.store.add('pets', {name: $scope.newPetName})
.done(function(newPet) {
// do nothing
});
};
$scope.removePet = function(index) {
var pet = $scope.pets[index];
hoodie.store.remove('pets', pet.id)
.done(function() {
// do nothing
});
};
hoodieArray.bind($scope, 'pets', 'pets');
// another controller
hoodie.store.on('change:pets', function (eventName, changedObject) {
// ...
});
&
https://speakerdeck.com/espylaub/offline-first-web-apps