Get into Breeze.js

Last week I’ve started to play with Breeze.js and it really seems to be a great tool for developing reach client side applications.

In this post I wanted to let you know about some of its core features and, perhaps, make you curious about it.

I’ve also made available a quick sample project if you want to see Breeze.js in action.

So, what is Breeze.js? 

Breeze.js is a JavaScript library that manages data in rich client applications.

How does it work?

Breeze creates dynamic objects,  that mirror your server-side objects. The properties of these objects can be bind to the controls on the UI and any change made on the data model, will be tracked and updated on the UI automatically.

What can I do with it?

There  are several quite interesting and useful features that Breeze.js provides:

  • Rich Queries with Linq-style syntax
  • Change tracking
  • Validation
  • Support for Entity Framework, Odata and Web API
  • Support for NoSQL, non-.Net and SOA back-ends
  • Data management
  • Batched saves
  • Support for various JavaScript Libraries like Knockout, Angular and Backbone

Rich Queries

Example of a simple query with filter and order:


var query = breeze.EntityQuery.from('Cities')
 .where('CountryName', '==', 'Portugal')
 .orderBy('CityName');

Remember, it’s JavaScript! Nice, right?

Track changes and do batched saves

With Breeze.js we can make every CRUD operation with its objects and save everything in a bulk operation.

Below a quick snippet:


// save all changes in one operation

manager.saveChanges()
 .then(function () { alert("changes saved"); })
 .fail(function () { alert("error saving"); });

The manager is a Breeze.js EntityManager and it is the service gateway and cache holder.

Quick sample

I’ve made a simple project where you can check Breeze.js in action.

It’s a small page that lists some world cities and you have a search form to filter the records.

The project was developed with ASP.Net MVC, EF Code First, Knockout and of course Breeze.js

https://github.com/nmoliveira/GetIntoBreezeJS

preview

References:

http://www.breezejs.com/documentation/introduction

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s