Angularjs Module that depends from AngularFire allows to make snapshots of an $firebaseObject, store versions in firebase, do rollback, go to prev version, undo, redo, go to a specific version and much more...
this repo is a fork of awesome https://github.com/marco64bit/Angular-Transaction-manager
```sh bower install AngularFire-Transaction-manager --save ```include firebase.transactionManager.js in your application
<script src="scripts/transactionManager.js"></script>
add firebase.transactionManager to your angular module
var app = angular.module('myApp', ['firebase.transactionManager']);
not yet.. comming...
or Open example folder and run
npm install grunt install bower install
run grunt server in example folder
//////// doc deprecated... to be updated. ////////
works only with $firebaseObject (not with primitives) like this
var obj = $firebaseObject(ref);
TransactionManager.snapshot save the actual state of passed object ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); ``` the result object contains a key snapshot ```js {a: 1, b: "test", snapshot: [{a: 1, b: "test"}]} ``` you can call snapshot() more than 1 time, the result object will contain a list of all snapshot ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); $scope.foo.b = "changed"; TransactionManager.snapshot($scope.foo); // $scope.foo will be: //{a: 1, b: "test", snapshot: [{a: 1, b: "test"}, {a: 1, b: "changed"}]} ```
TransactionManager.rollback applies the last snapshot ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); $scope.foo.b = "test2"; // now foo is -> {a: 1, b: "test2"} TransactionManager.rollback($scope.foo); // now foo is -> {a: 1, b: "test"} ```
TransactionManager.canRollback returns true in case it has a snapshot and actual state is different from last snapshot ```js TransactionManager.canRollback($scope.foo); ```
TransactionManager.canRestorePrevious return true if passed object has a previous snapshot (old
TransactionManager.restorePrevious Restore to the state of previous snapshot version. ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); // now foo is -> {a: 1, b: "test"} $scope.foo.b = "test2"; TransactionManager.snapshot($scope.foo); // now foo is -> {a: 1, b: "test2"} TransactionManager.restorePrevious($scope.foo); // now foo is -> {a: 1, b: "test"} ```
TransactionManager.clear Remove all snapshots ```js TransactionManager.clear($scope.foo); ```
TransactionManager.hasSnapshot returns true if passed object has at least 1 snapshot ```js TransactionManager.hasSnapshot($scope.foo); ```