r/angularjs • • Dec 23 '16

Angular 1.6.1 out (bug fixes, no breaking changes)

https://github.com/angular/angular.js/blob/master/CHANGELOG.md#161-promise-rectification-2016-12-23
19 Upvotes

9 comments sorted by

1

u/robotzuelo Dec 23 '16

I thought that they where going to remove .success and .error on the 1.6 version, did that change?

2

u/Dark_Cow Dec 24 '16

The previous blog posts states it's removed. Now if they can make $resource more sane...

1

u/robotzuelo Dec 26 '16

what is $resource for? rest apis? I've never used it, usually I create a factory for the rest calls or use restangular. Am I missing something good from $resource?

3

u/Dark_Cow Dec 27 '16

I suppose all $resource does its creates a CRUD endpoint client. AKA HTTP get/put/post/delete on a url like /api/users

Unfortunatly the API is weird and doesn't strictly follow promise style, and instead uses callbacks. Additionally, the fact that objects get added on parameters is just weird. Like

var users = User.query(function() {
    console.log( user.lastName ); // Doe
});
console.log( user.lastName ); // Undefined? What!
// later...
console.log( user.lastName ); // Ohh.. now it is Doe, like a second later...

or better yet, the addition of functions!

var users = User.query();
// later...
users.$cancelRequest(); // Yuck...

I really dislike it and prefer to use $http straight up, as $resource is just quite ugly. First of all, the 'data' object is actually a promise, and it's data doesn't exist until the resource responds, Only the angular digest cycle understands this, and your javascript has to watch the resource! Its one redeeming factor is url interpolation like '/api/user/:userId'...

$http is just less of a black blox, trying to explain a controller using $resource is impossible, as it promotes no clear flow of data. (which brings into another conversation about redux)

restangular is good, but it comes at 20.7KB in size! What! It better do the dishes at 20KB!

1

u/robotzuelo Dec 27 '16

Thanks for taking the time to respond.

0

u/[deleted] Dec 23 '16

[deleted]

2

u/onFilm Dec 23 '16

Sounds like you need to do more testing. You can complain about frameworks all you want; they all have their strengths and weaknesses, but testing is a lot more important in my opinion, especially if you're dealing with customers/clients.

Also get your dependencies management cleaned up so you stop loading odd versions.

4

u/onFilm Dec 23 '16

/u/kingoffortlauderdale

Why did you stop the discussion and deleted your comments?

1

u/death_by_caffeine Dec 23 '16

Try Ember, you might like it.

1

u/outc4sted Dec 23 '16

I've been really liking React + Redux. Check into the Redux docs (which are really well done) if you want your architecture to resemble functional programming.