npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-fat-model

v0.4.2

Published

Angular provider used to aggregates models in groups.

Downloads

9

Readme

Angular-fat-model

Fat model is used to better coordinate models in application. Allows to aggregate then in groups in order to fetch only groups which are currently needed.

Getting Started

This plugin was tested on Angular in version 1.3.x, 1.4.x and 1.5.x

Instalation

bower install angular-fat-model --save-dev

Add lib into script

<script type="text/javascript" src="../bower_components/angular/angular.js"></script>
(function () {
  "use strict";

  var app = angular.module('App', ['FatModelProvider']);

  app.run([
    '$FatModelProvider',
    '$timeout',
    '$q',
    '$http',
    function ($FatModelProvider, $timeout, $q, $http) {
      // Method just only for demo
      var fetch = function () {
        var defer = $q.defer();

        $http({
          method: 'GET',
          url: 'http://localhost',
          withCredentials: true
        }).success(function () {
          defer.resolve.apply(defer.resolve, arguments);
        }).error(function () {
          defer.reject.apply(defer.reject, arguments);
        });

        return defer.promise;
      };

      $FatModelProvider.register({
        name: 'model-1',
        promise: fetch,
        refresh: true,
        groups: ['group-1'],
        success: function () {
          console.log('success 1');
        },
        error: function () {
          console.log('error 1');
        }
      });

      $FatModelProvider.register({
        name: 'model-2',
        promise: fetch,
        refresh: true,
        groups: ['group-1'],
        success: function () {
          console.log('success 1');
        },
        error: function () {
          console.log('error 1');
        }
      });

      $FatModelProvider.register({
        name: 'model-3',
        promise: fetch,
        refresh: true,
        groups: ['other-group'],
        success: function () {
          console.log('success 1');
        },
        error: function () {
          console.log('error 1');
        }
      });

      $FatModelProvider.$on('FatModel:fetch:started', function () {
        console.log('Started fetching');
      });

      $FatModelProvider.$on('FatModel:fetch:finished', function () {
        console.log('Finished fetching - Do something when all models have been fetched!');
      });

      $FatModelProvider.$on('FatModel:fetch:error', function ($event, error) {
        console.log('Fetching with errors', errors);
      });

      $FatModelProvider.getModel('model-1').$on('FatModel:fetch:started', function () {
        console.log('Started fetching model-1');
      });

      $FatModelProvider.getModel('model-2').$on('FatModel:fetch:finished', function () {
        console.log('Finished fetching model-1');
      });

      $FatModelProvider.$on('FatModel:fetch:main:started', function () {
        console.log('Started fetching group main');
      });

      $FatModelProvider.$on('FatModel:fetch:main:finished', function () {
        console.log('Finished fetching group main');
      });

      $FatModelProvider.fetch().then(function (response) {
        console.log('All fetch response:', response);
      });

      // OR

      $FatModelProvider.fetchGroup(['other']).then(function (response) {
        console.log('Group fetch response:', response);
      });

      // OR

      $FatModelProvider.getModel('model-1').fetch().then(function (response) {
        console.log('Model-1 response:', response);
      });
  ]);
})();

Options

Release History

  • 2016-01-14 v0.4.2 Fixed small bugs & fixed error handling.
  • 2015-11-21 v0.4.1 Change response of fetch and fetchGroup methods.
  • 2015-11-21 v0.4.0 Removed success and error callbacks. Returns promise on fetch and fetchGroup call.
  • 2015-11-21 v0.3.0 Added success and error callbacks.
  • 2015-11-21 v0.2.2 Updated bower and package files on new keywords.
  • 2015-11-05 v0.2.1 Removed timeouts.
  • 2015-10-30 v0.2.0 Triggers events for groups.
  • 2015-09-28 v0.1.0 First version of plugin.

Task submitted by Tomasz Czechowski