3. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
What’s ?
JS library aimed to manage data in rich client applications
Implements the Open Data Protocol (OData) query
standard
Ships with adapters for the ASP.NET Web API and for
OData
4. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Communication
DAL
UI
BL (MV*)
Offline Storage
Entities
Module Module Module
Server
5. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Why ?
It’s free
Simplify data query tasks
Manage client side data caching
Support batch operations
Support all modern browsers on desktop and mobile
devices (ECMAScript 5)
Out-of-box support for Knockout, Angular, and Backbone
Well documented
Has roadmap
6. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Query Data
LINQ style syntax
Execute query asynchronously with a Promise
Query related entities
Flatten entity graphs
Query server, cache, or both
If a query can be expressed in OData syntax, it can be
expressed in Breeze
7. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Query Data
//define query
var query = breeze.EntityQuery().from("Customers")
.where("CompanyName", "startsWith", "C")
.orderBy("CompanyName");
//execute query
var manager = new breeze.EntityManager(serviceName);
manager.executeQuery(query)
.then(querySucceeded)
.fail(queryFailed);
8. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Query Data
Breeze resolves this query into an HTTP GET request
formatted as an OData URI
EntityManager reshapes the result JSON data into entities
and merges them into its cache
The Promise object forwards entities to the caller’s
success callback
10. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Client Side Caching
Cache entities locally on the JavaScript client
Query client Cache, Server or both
Navigate among entities in cache
11. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Client Side Caching
/* Query the server, cache, or both */
var query = breeze.EntityQuery("Customers");
// execute query asynchronously on the server
manager.executeQuery(query).then(querySuccess).fail(queryFail);
// execute query synchronously on local cache
var customers = manager.executeQueryLocally(query)
// fetch customer by id from cache (if found) or remotely
var checkCacheFirst = true;
manager.fetchEntityByKey("CompanyName", 42, checkCacheFirst).then
(fetchSuccess).fail(fetchFail);
13. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Track Changes
Breeze Entities are self-tracking – they manage their own
state via entityAspect.entityState
Refresh an entity to its current state on the server or revert
changed entities to their original values
Get notifications about the entities that enter, leave, and
change in cache
14. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Track Changes
Examine entity state via entityAspect.entityState
Respond to entity property change via
entityAspect.propertyChanged event
Respond to change validation errors via
entityAspect.validationErrorsChanged event
15. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Track Changes
/* Change tracking */// save all changes (if there are any)
if (manager.hasChanges())
{
manager.saveChanges().then(saveSucceeded).fail(saveFailed);
}
// listen for any change to a customer
customer.entityAspect.propertyChanged.subscribe(somethingHappened);
// listen for validation errors
customer.entityAspect.validationErrorsChanged.subscribe(updateValid
ationUI);
כמה שפחות שקפים ויותר הדגמות חיות הדגמות חיות מבוססות על דרישות עסקיות של לקוח (סיפור הנבנה בהדרגה) לכל נושא 3 שקפים: תיאור קצר של יתרונות, הצגת קוד לדוגמא והדגמה חיהצמידות מינימלית לצד שרת
executeQuery method is asynchronousand returns a promise to call back either success handler or failure handler