BreezeJs features already implemented by AngularJs?

126 views Asked by At

I was suggested to use BreezeJs for an AngularJs project and I saw that it has some really interesting features.

In my case the main interests would be in caching, tracking changes, some light querying, and validation. I think those features can be implemented at some level in AngularJs without too much trouble:

  • Caching can be accomplished by storing the data, or API calls results in objects in services? Given the services nature, the data will be accessible throughout the app, and they will be cached.
  • Tracking changes is done by angular with 2-way data binding. Here you may drop some of that 2-way binding(less watchers in Angular), but Breeze will do that checking in parallel.
  • Queries are something I don't need to be very complex, so Angular filters will do the work. The same thing applies to validations, I have enough from Angular.

For data handling I saw that the EntityManager can be really handy.

I get the feeling that for applications, not too complex, you can achieve almost all the things BreezeJs offers directly in AngularJs, in a nice clean way, without the need of adding one more library.

What am I missing from BreezeJs?

1

There are 1 answers

1
Ward On BEST ANSWER

You're missing just about everything ;-)

Angular doesn't do any of the things you mentioned.

  • Breeze caching ensures entity identity, just-in-time maintenance of navigation properties, entity dirty-checking, query-over-cache, and much more. None of that in Angular "cache".

  • Angular doesn't track changes to entities. It tracks changes to visible bindings; if it ain't on screen, it ain't tracked. Once it is no longer on screen, the "tracking" is gone. There is no notion of model change-state in Angular.

  • Angular filters are for in-memory filtering, not querying a server (or a cache).

  • Angular validations are purely HTML-facing. They don't validate the model. They do not prevent attempts to save invalid entities. They offer no means to answer the question "is this entity-or-property valid and if not, how is it invalid?". With ng you ask about the validity of forms, not entities. It can't help you enforce a business rule everywhere; the best you can do is try to decorate every HTML element that touches a model property with every business rule applicable validation (which may mean minting custom directives for your custom validation rules). Good luck with that.

I am not knocking Angular at all. Angular concentrates on functionality you need to organize your application and interact with HTML. It throws in $http to make server requests but that's as far "down" into the model layer as it goes. In fact, it quite deliberately (and properly IMO) makes no assumptions about the model. Therefore, it cannot do the things that Breeze does nor should it.

If you want to delve a bit deeper, you might look at the slides I presented at ngConf 2014 that try to explain what Breeze does and the synergy between Angular and Breeze.

I don't know whether you need Breeze for your application. But there is nothing in Angular that approximates Breeze. So if you want the functionality in Breeze you have two choices:

  1. use Breeze
  2. roll your own framework, leveraging whatever you can from ng (of which little is directly applicable).

Hope that clarifies.