0
votes

I am new to Breeze.js but have used NgRX.

In one of my project which is considered large project (6 months development time), my client have a special request to use Breeze.js.

I read through documentation of Breeze.js. I see the main advantage is that Breeze enables Angular frontend apps to execute GET and POST query to the api server using rich schema.

eg.

var query = new breeze.EntityQuery()
    .from("Products")
    .where("Category.CategoryName", "startswith", "S");

Can Breeze also be used to manage States of UI and Entity on the frontend like what NgRX and NgRX Entity or NgRX Data ?

Please advice.

1
You say you read through documentation for Breeze.js. Did it mention that it could be used for state management? - R. Richards
Not mentioned anywhere about state management. Just rich query. - edmond tm
The Limitations page for NgRx-Data mentions Breeze as an alternative that overcomes some of NgRx's limitations. - Steve Schmitt
Steve, well said. NgRx Data does have limitations when it comes to writing queries from front end. - edmond tm

1 Answers

3
votes

Yes, and Breeze is much better at it IMHO. (I'm one of the maintainers of Breeze).

Breeze is not for managing UI state. It is for managing entities, especially related entities.

Breeze maintains a cache of entities. Breeze keeps track of the state of each entity (Added, Modified, Deleted, Unchanged) in the cache.

When an entity is modified, it keeps track of the original values that the entity had when it came from the server, so that you can determine what changed and revert the changes if desired.

Breeze uses metadata to know about the relationships between entities. Customers have Orders that have OrderLineItems that relate to Products etc. If you query Customers and later query Orders, Breeze will automatically hook up the entity relationships in the cache, so that the Customer will have Orders and each Order will have a Customer. You can also query several entity types at once, and Breeze will hook them up automatically.

When you make changes to entities, Breeze keeps track of which entities have changed. Then you can save all the changed entities at once, in a single transaction.

I think the rich querying features of Breeze, while nice, are a relatively minor feature compared to the entity management.

I could go on, obviously. But I've tried NgRx Data (and I know the maintainers) and Breeze is more powerful and easier to use.