Hacker News new | ask | show | jobs
by adelevie 4650 days ago
Being able to avoid $scope.$apply() will certainly be nice.

As it stands now, if you want to leave the Angular reservation and use something like the Parse JS SDK (which is a customized set of Backbone models) your code will be littered with $scope.$apply(). Not very DRY, and also adds, from the dev's point of view, a needless level of nesting functions.

2 comments

... how does this have anything to do with DRY? You're calling $scope.$apply because you're re-entering AngularJs with new data and need to start off the dirty checking process.

This isn't repeated logic. This is a core function of the framework that's meant to be used exactly like that.

It's meant to be called that many times if you're doing that many things outside of Angular and need to sync your models.

Parse.com has a perfectly capable REST API[1] that you can use with Angular's $resource. If you use Restangular, then your life becomes even easier. It won't be as convenient as using their JS SDK, but your code will end up looking much cleaner.

---

[1] https://www.parse.com/docs/rest

I've spent my fair share of time pouring over Parse's REST docs[1][2]. It's a fairly large undertaking to fully support all REST features, so it's still a decent trade-off to just use the JS SDK. If there are any Parse + Angular REST client projects, I'd be happy to contribute some code.

[1] https://github.com/adelevie/parse_resource

[2] https://github.com/adelevie/parse-ruby-client