Giter Club home page Giter Club logo

model-factory's Introduction

model-factory

A tool for building RESTful models for AngularJS

Developing

Install dependencies:

npm install
bower install

Build:

grunt build

Watch and run unit tests:

grunt dev

TODO

  • docs
  • examples
  • add directives to handle suppressing model changes from the view to the model
  • suggestions?

Design

This is a simple model factory inspired by angular's $resource and built on top of jmdobry's awesome angular-cache.

The model factory builds simple resources that implement REST/CRUD functions with the help of angular-cache. The model-factory creates a single point of truth--all references to an instance point to the same object in memory no matter how many requests you make. This cuts down on memory usage and ensures that the model state is identical across all instances of the model in your controllers. The model-factory also decreases time to render by returning a cached value instead of making multiple requests.

CAVEAT

Using angular's two-way binding can lead to unforeseen consequences because all references to a model point to the same object in memory. Let's say a model is bound to an input using ng-model and displayed somewhere else on the page. Editing the input will cause the other value to update immediately. The server instance of the model will only be updated by calling the model-factory's create or save call. Make sure to keep this in mind while using the model-factory in your app. (visual aids to come).

model-factory's People

Contributors

avacooley avatar b-ryan avatar bi1yeu avatar glo28557 avatar karstendick avatar kurtwheeler avatar ravsinha avatar ynicolaou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

model-factory's Issues

depends on underscore

I tried using this and don't have underscore as a dependency. This is not really a necessary dependency for this library to have.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.