A data cache with events for AngularJS
JavaScript
Latest commit f4a76e4 Nov 27, 2014 @zensh zensh update dev dependencies
Permalink
Failed to load latest commit information.
examples v0.1.0 Sep 22, 2014
test v0.1.0 Sep 22, 2014
.gitignore v0.1.0 Sep 22, 2014
.jshintrc v0.1.0 Sep 22, 2014
.travis.yml v0.1.0 Sep 22, 2014
LICENSE Initial commit Sep 22, 2014
README.md fix readme Sep 27, 2014
bower.json add warehouse.getAll Sep 23, 2014
component.json add warehouse.getAll Sep 23, 2014
gulpfile.js update for gulp Oct 14, 2014
index.js add warehouse.getAll Sep 23, 2014
package.json update dev dependencies Nov 27, 2014

README.md

ng-warehouse v0.2.0 Build Status

A data cache with events for AngularJS.

DEMO

angular.module('demoApp', ['data.warehouse'])
  .controller('DemoCtrl', ['$scope', 'warehouse', 'store2', function ($scope, warehouse, store2) {

    // use localStorage with [store2](http://github.com/nbubna/store)
    var articleCache = warehouse('users', store2);

    // or user memory cache
    var userCache = warehouse('users');

    $scope.userList = userCache.getAll();

    $scope.articleList = articleCache.getAll();

    userCache.bind($scope, 'add', function (userId, user) {
      $scope.userList.push(user);
      if (!$scope.$$phase) $scope.$apply();
    });

    articleCache.bind($scope, 'add', function (articleId, article) {
      $scope.articleList.push(article);
      if (!$scope.$$phase) $scope.$apply();
    });

    //...more

  }]);

Installation

Bower:

bower install ng-warehouse
<script src="/pathTo/jsonkit/jsonkit.js"></script>
<script src="/pathTo/ng-warehouse/index.js"></script>

API

var cache = warehouse(namespace);

warehouse(namespace)

warehouse(namespace, store2)

warehouse.getAll()

cache.has(key)

cache.get(key)

cache.getAll()

cache.set(key, value[, silent])

cache.add(key, value[, silent])

cache.remove(key[, silent])

cache.bind(scope, type, listener)

cache.destroy()