Js il 2013 breeze.js
-
Upload
eyal-vardi -
Category
Technology
-
view
3.379 -
download
0
description
Transcript of Js il 2013 breeze.js
![Page 1: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/1.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Yaniv ArditiCTO, Dynamics Divisions
E4D Solutions [email protected]
http://blogs.microsoft.co.il/blogs/rdt/
Israel JavaScript Conference
![Page 2: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/2.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Agenda ? Query data Client side Caching Track changes Resources Q&A
![Page 3: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/3.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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
![Page 4: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/4.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Comm
unication
DAL
UI
BL (MV*)
Offline Storage
Entities
Module Module Module
Server
You are here
![Page 5: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/5.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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
![Page 6: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/6.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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
![Page 7: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/7.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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);
![Page 8: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/8.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Query Data Breeze resolves this query into an HTTP GET
request formatted as an OData URIhttp://www.example.com/api/Northwind/Customers?$filter=startswith(CompanyName,'C') eq true&$orderby=CompanyName
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
![Page 10: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/10.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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
![Page 11: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/11.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Client Side Caching/* Query the server, cache, or both */var query = breeze.EntityQuery("Customers");
// execute query asynchronously on the servermanager.executeQuery(query).then(querySuccess).fail(queryFail);
// execute query synchronously on local cachevar customers = manager.executeQueryLocally(query)
// fetch customer by id from cache (if found) or remotelyvar checkCacheFirst = true;manager.fetchEntityByKey("CompanyName", 42, checkCacheFirst).then(fetchSuccess).fail(fetchFail);
![Page 12: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/12.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Client Side Caching
![Page 13: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/13.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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
![Page 14: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/14.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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
![Page 15: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/15.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | 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 customercustomer.entityAspect.propertyChanged.subscribe(somethingHappened);
// listen for validation errorscustomer.entityAspect.validationErrorsChanged.subscribe(updateValidationUI);
![Page 17: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/17.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Resources Breeze central
http://www.breezejs.com
Breeze SDKhttp://www.breezejs.com/sites/all/apidocs/index.html
Trouble Shootinghttp://stackoverflow.com/questions/tagged/breeze
![Page 18: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/18.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
Thanks
Yaniv ArditiCTO, Dynamics Divisions
E4D Solutions [email protected]
http://blogs.microsoft.co.il/blogs/rdt/
![Page 19: Js il 2013 breeze.js](https://reader035.fdocuments.us/reader035/viewer/2022070315/554f4f15b4c905b9508b4c1c/html5/thumbnails/19.jpg)
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |
www.js-il.com
18.6.13