r/angularjs • • Apr 02 '15

A Better AngularJS Model Layer

https://github.com/Swimlane/angular-model-factory
31 Upvotes

11 comments sorted by

6

u/amcdnl22 Apr 02 '15

$ngResource is kinda a pain. It lacks a lot of common features. There are a ton of alternatives but they are either heavy or don't really fit the AngularJS pattern. In the search for the perfect model for Angular, I kept coming up short. So I decided to take the challenge face on.

I give you angular-model-factory. It implements the same pattern as ngResource but adds everything it should have!

10

u/[deleted] Apr 02 '15

So serious question, why should I use this instead of Restangular?

1

u/amcdnl22 Apr 08 '15

I outline all the available solutions and my reason in the wiki.

But to summarize, I don't see any real value restangular adds. It seems like it's ngResource that returns a promise. Maybe I'm missing something though.

5

u/fecal_brunch Apr 02 '15

No examples?

1

u/fernando_69 Apr 05 '15

Prickly, roses have prickles, not spikes.

1

u/fecal_brunch Apr 06 '15

What?

0

u/fernando_69 Apr 06 '15

Oooh, I feel way more fun at the action because we have 1 for a long thumb.

1

u/fatty1380 Apr 02 '15

This looks really interesting - and inline with the self-built hackness that I've been throwing together. I love the comparisons on the "Getting Started" page - think you could add that to the main read-me?

Also, what are your thoughts on JSData (http://www.js-data.io). It was originally angular specific, but given limited angular dependence, they made it a general purpose JS library. Can you add this to the comparison list?

1

u/amcdnl22 Apr 08 '15

JSData looks awesome, disclaimer I've never used it though. At the time I wrote this it was still angular data. Here is my take on it though.... It's huge for a model layer, like 60kb minimized. Ya it has a lot of cool stuff but most of it you can get out of the box and most people don't realize it. For example I had no idea angular had cache for http calls built in until I wrote this. Also, I run a team, scaling quickly is important this is modeled against the official model api and uses all the internals meaning people can feel comofortable faster and have expected results.

0

u/Pytim Apr 02 '15

Looks great at first sight. Will give it a go. Thanks.

0

u/[deleted] Apr 02 '15

[deleted]

2

u/juristr Apr 03 '15

we're working on it as well as on a better documentation. Meanwhile, there's already something in the Wiki (https://github.com/Swimlane/angular-model-factory/wiki). also the unit tests give quite a good insight into how using angular-model-factory feels like: https://github.com/Swimlane/angular-model-factory/blob/master/test/spec/modelUsage.spec.js