SlideShare une entreprise Scribd logo
1  sur  19
Understanding
HTML5
Data Services
Thomas Burleson
Mindspace, LLC
www.linkedin.com/in/ThomasBurleson
www.gridlinked.info
with
sample code
July, 2013
Sunday, July 7, 13
Server
Tier
Java
ColdFusion
PHP
ASP
Middle
Tier
HTML5
Client
Tier
Understanding
HTML5 DataServices
HTML5 Single-Page-Applications (SPA) are thin-client applications that exchange data with remote data services (RDS).
RDS endpoints may connect directly to a Server-Tier having `enterprise-wide` APIs
Often RDS endpoints connect to Middle-Tier, cloud-based services called Web Services
HTTP WebServices most often marshall data as JSON or XML
Sunday, July 7, 13
Using
Middle-Tier Web Services
InventoryHTML5
Client
Tier
Authentication
Sessions
Users
Billing
Authentication
Users
Accounts
Orders
Middle
Tier
Web Services work as facades to server-tier `complexity`
Web Services are best used when implemented for specific client UX needs
Web Services hide server-tier complexities/dependencies from client-tier needs
Middle-tier (Web Services) are not required… but often optimize persistence, data access, data caching, and
even aggregate functionality for thin-client applications.
Sunday, July 7, 13
Using
Client-Tier Delegates
Inventory
Authentication
Sessions
Users
Billing
Authentication
Users
Accounts
Orders
Web
Services
Client
Tier
HTML5
SPA
Auth
Users
Delegates
Delegates APIs often match the Web Services APIs
Delegates are used to proxy `controller` requests to remote WebServices
Delegates are responsible for serializing, deserializing, and transforming data
Delegates manage request/response pairs to/from WebServices respectively.
Sunday, July 7, 13
Client-Tier
Architecture Layers
Authentication
Users
Middle
Tier
Client-Tier
HTML5 or Flash SPA
Auth
Users
Delegates
Views
Controllers
Models
Models, Views, Controllers, Delegates
Best Practices:
Only Controllers interact with Delegates
Delegates are `proxies` to remote APIs
Delegates are ASYNCHRONOUS
Delegates should use Promises (or equivalents)
Sunday, July 7, 13
Authenticati
on
Users
Middle
Tier
Client-Tier
HTML5 or Flash SPA
Auth
Users
Delegates
Views
Web Services
Layer
Data Services
Layer
Client-Tier
Architecture Layers
Sunday, July 7, 13
Implementation
What are Delegates?
Could be as simple as a generic Javascript object.
For example, consider an Authentication delegate with only three (3)
public functions.
Promises are the recommend solution in order to support the
asynchronous nature of remote WebService calls.
It is important to note that all Delegate public functions return Promises; since all public
functions are async and will respond with real data response(s) at a future point in time
Delegates are objects with public functions.
Delegates are `proxies` to remote Web Services.
Delegates are client-side Data Services.
Sunday, July 7, 13
(1) What are the public functions available
(2) What are the arguments for each function
(3) What are the data structures in the WebService responses
(4) What are the errors possible from each function call
Application Programming Interfaces (API) simply clarify:
Implementation
What are Delegate API(s)?
Sunday, July 7, 13
Implementation
What are Delegate API(s)?
Consumers of the AuthDelegate API can use:
login( )
logout( )
loadPrivileges( )
(1) functions =
login( userName, password )(2) arguments =
login( ) -> { sessionID : <String> }
logout( ) -> true | false
loadPrivileges( ) -> { level : <int> }
(3) responses =
The API is now more easily understood.
Sunday, July 7, 13
Implementation
How are Delegates used?
Call Delegate API
Call Delegate API
Controllers use delegates and
attach .then() handlers for responses.
Note that the controller has no
knowledge of how the login() or
logout() methods actually work… so
this delegate reference could be either
a real service or a mock service!
Sunday, July 7, 13
Implementation
How are Delegates used? (cont.)
Call Delegate API
Using Delegate API ResponsesInjected `session` model
Controllers use delegates and attach
handlers for responses.
Notice that the LoginController has no
knowledge of `how` the login() or
logout() methods actually work…
This means that authDelegate could be
an instance of real service or a mock
service; since both have the same API!
Sunday, July 7, 13
Implementation
How to build a Delegate ?
Use generic Javascript object to outline the API
Sunday, July 7, 13
Implementation
How to build a Delegate ?
Use Module Pattern and AngularJS to define authDelegate instance.
NOTE: the authDelegate can then be injected into Controllers.
Sunday, July 7, 13
Implementation
How to build a Mock Delegate?
Step 3: Implement API methods with asynchronous, mock responses
inline data construction
Delay response
Publish API
Here we used $timeout with a 2-sec
delay; to simulate an asynchronous
response.
Notice that we did not load any
external mock data… instead we
generated inline the data structures
expected in the responses.
Sunday, July 7, 13
Implementation
Mock Delegate using External Data?
Implement API method internally using AngularJS $http to load external mock data;
captured in the /data/login.json file.
Load external mock data
extract data structures
Here $http.get() also returns a
Promise.
Our AuthDelegate .then()
handler intercepts that response
and extracts the desired data
structures…
This occurs before the
LoginController .then() handler
is notified.
Sunday, July 7, 13
Implementation
Building a DataServices Library
How does your architecture scale if you have 2..n Delegates?
How do you separate Delegate factory/service definitions from your main application (AuthenticationDemo is shown below )?
Note: Each delegate constructor function has been collapsed. Expanded
you can imagine that the above approach gets `messy` VERY
quickly...
Question:
Sunday, July 7, 13
Implementation
Building a DataServices Library
1) Define all your data services in a separate JS file.
2) Register your data services within a custom, data-service module.
3) Register your module/library as a dependent module for your main App
4) Inject Delegate instances into your Controllers
Answer:
MyAppDataServices.js
DemoApp.js
Sunday, July 7, 13
Implementation
How to package a DataServices Library
AllDelegates.js
Build packages
Publish...
- Outside of AngularJS -
Sunday, July 7, 13
Implementation
How to package a DataServices Library
MyAppDataServices.js- Using AngularJS -
Register Constructors...
Sunday, July 7, 13

Contenu connexe

Tendances

Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaEvolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaMongoDB
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Examplekamal kotecha
 
Web Services Container
Web Services ContainerWeb Services Container
Web Services ContainerJorgen Thelin
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudSharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudDanny Jessee
 
Entity framework and how to use it
Entity framework and how to use itEntity framework and how to use it
Entity framework and how to use itnspyre_net
 
Entity Manager
Entity ManagerEntity Manager
Entity Managerpatinijava
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical filevarun arora
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoMoldova ICT Summit
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitIMC Institute
 
Java Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreJava Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreIMC Institute
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083Divyam Pateriya
 
Claims-Based Identity in SharePoint 2010
Claims-Based Identity in SharePoint 2010Claims-Based Identity in SharePoint 2010
Claims-Based Identity in SharePoint 2010Danny Jessee
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and exampleShailesh singh
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework OverviewEric Nelson
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaEdureka!
 

Tendances (20)

Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaEvolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
Web Services Container
Web Services ContainerWeb Services Container
Web Services Container
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudSharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
 
Entity framework and how to use it
Entity framework and how to use itEntity framework and how to use it
Entity framework and how to use it
 
Interview questions on asp
Interview questions on aspInterview questions on asp
Interview questions on asp
 
Ejb6
Ejb6Ejb6
Ejb6
 
Entity Manager
Entity ManagerEntity Manager
Entity Manager
 
Hibernate
HibernateHibernate
Hibernate
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai Shevchenko
 
RESTful Day 5
RESTful Day 5RESTful Day 5
RESTful Day 5
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
 
Java Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreJava Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : Datastore
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
Claims-Based Identity in SharePoint 2010
Claims-Based Identity in SharePoint 2010Claims-Based Identity in SharePoint 2010
Claims-Based Identity in SharePoint 2010
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and example
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | Edureka
 

Similaire à Understanding AngularJS HTML5 DataServices

Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)Clarence Ngoh
 
ANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATA
ANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATAANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATA
ANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATAIJCSEIT Journal
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineJava Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineIMC Institute
 
Dh2 Apps Training Part2
Dh2   Apps Training Part2Dh2   Apps Training Part2
Dh2 Apps Training Part2jamram82
 
Application server vs Web Server
Application server vs Web ServerApplication server vs Web Server
Application server vs Web ServerGagandeep Singh
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSUFYAN SATTAR
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAElynneblue
 
ADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and SynchingADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and SynchingSteven Davelaar
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web DevelopmentRobert J. Stein
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Igor Moochnick
 
Resume_Sandip_Mohod_Java_9_plus_years_exp
Resume_Sandip_Mohod_Java_9_plus_years_expResume_Sandip_Mohod_Java_9_plus_years_exp
Resume_Sandip_Mohod_Java_9_plus_years_expSandip Mohod
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJSGregor Woiwode
 
Android rest client applications-services approach @Droidcon Bucharest 2012
Android rest client applications-services approach @Droidcon Bucharest 2012Android rest client applications-services approach @Droidcon Bucharest 2012
Android rest client applications-services approach @Droidcon Bucharest 2012Droidcon Eastern Europe
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaDavid Chandler
 
Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobileFlavius-Radu Demian
 

Similaire à Understanding AngularJS HTML5 DataServices (20)

Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)Having Fun Building Web Applications (Day 1 Slides)
Having Fun Building Web Applications (Day 1 Slides)
 
ANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATA
ANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATAANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATA
ANDROID BASED WS SECURITY AND MVC BASED UI REPRESENTATION OF DATA
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineJava Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
 
Dh2 Apps Training Part2
Dh2   Apps Training Part2Dh2   Apps Training Part2
Dh2 Apps Training Part2
 
Application server vs Web Server
Application server vs Web ServerApplication server vs Web Server
Application server vs Web Server
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
 
Express node js
Express node jsExpress node js
Express node js
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAE
 
ADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and SynchingADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and Synching
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Resume_Sandip_Mohod_Java_9_plus_years_exp
Resume_Sandip_Mohod_Java_9_plus_years_expResume_Sandip_Mohod_Java_9_plus_years_exp
Resume_Sandip_Mohod_Java_9_plus_years_exp
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
Android rest client applications-services approach @Droidcon Bucharest 2012
Android rest client applications-services approach @Droidcon Bucharest 2012Android rest client applications-services approach @Droidcon Bucharest 2012
Android rest client applications-services approach @Droidcon Bucharest 2012
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for Java
 
Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobile
 

Plus de Thomas Burleson

The Flash to HTML5 Opportunity
The Flash to HTML5 OpportunityThe Flash to HTML5 Opportunity
The Flash to HTML5 OpportunityThomas Burleson
 
Visualize Deep Links with Flash and Swiz
Visualize Deep Links with Flash and SwizVisualize Deep Links with Flash and Swiz
Visualize Deep Links with Flash and SwizThomas Burleson
 
Building Multilanguage (i18n) Flex Applications
Building Multilanguage (i18n) Flex ApplicationsBuilding Multilanguage (i18n) Flex Applications
Building Multilanguage (i18n) Flex ApplicationsThomas Burleson
 
Understanding Flex Data Services
Understanding Flex Data ServicesUnderstanding Flex Data Services
Understanding Flex Data ServicesThomas Burleson
 

Plus de Thomas Burleson (6)

The Flash to HTML5 Opportunity
The Flash to HTML5 OpportunityThe Flash to HTML5 Opportunity
The Flash to HTML5 Opportunity
 
Function currying
Function curryingFunction currying
Function currying
 
Visualize Deep Links with Flash and Swiz
Visualize Deep Links with Flash and SwizVisualize Deep Links with Flash and Swiz
Visualize Deep Links with Flash and Swiz
 
Building Multilanguage (i18n) Flex Applications
Building Multilanguage (i18n) Flex ApplicationsBuilding Multilanguage (i18n) Flex Applications
Building Multilanguage (i18n) Flex Applications
 
Understanding Flex Data Services
Understanding Flex Data ServicesUnderstanding Flex Data Services
Understanding Flex Data Services
 
Flex Behavior Injection
Flex Behavior InjectionFlex Behavior Injection
Flex Behavior Injection
 

Dernier

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 

Dernier (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

Understanding AngularJS HTML5 DataServices

  • 1. Understanding HTML5 Data Services Thomas Burleson Mindspace, LLC www.linkedin.com/in/ThomasBurleson www.gridlinked.info with sample code July, 2013 Sunday, July 7, 13
  • 2. Server Tier Java ColdFusion PHP ASP Middle Tier HTML5 Client Tier Understanding HTML5 DataServices HTML5 Single-Page-Applications (SPA) are thin-client applications that exchange data with remote data services (RDS). RDS endpoints may connect directly to a Server-Tier having `enterprise-wide` APIs Often RDS endpoints connect to Middle-Tier, cloud-based services called Web Services HTTP WebServices most often marshall data as JSON or XML Sunday, July 7, 13
  • 3. Using Middle-Tier Web Services InventoryHTML5 Client Tier Authentication Sessions Users Billing Authentication Users Accounts Orders Middle Tier Web Services work as facades to server-tier `complexity` Web Services are best used when implemented for specific client UX needs Web Services hide server-tier complexities/dependencies from client-tier needs Middle-tier (Web Services) are not required… but often optimize persistence, data access, data caching, and even aggregate functionality for thin-client applications. Sunday, July 7, 13
  • 4. Using Client-Tier Delegates Inventory Authentication Sessions Users Billing Authentication Users Accounts Orders Web Services Client Tier HTML5 SPA Auth Users Delegates Delegates APIs often match the Web Services APIs Delegates are used to proxy `controller` requests to remote WebServices Delegates are responsible for serializing, deserializing, and transforming data Delegates manage request/response pairs to/from WebServices respectively. Sunday, July 7, 13
  • 5. Client-Tier Architecture Layers Authentication Users Middle Tier Client-Tier HTML5 or Flash SPA Auth Users Delegates Views Controllers Models Models, Views, Controllers, Delegates Best Practices: Only Controllers interact with Delegates Delegates are `proxies` to remote APIs Delegates are ASYNCHRONOUS Delegates should use Promises (or equivalents) Sunday, July 7, 13
  • 6. Authenticati on Users Middle Tier Client-Tier HTML5 or Flash SPA Auth Users Delegates Views Web Services Layer Data Services Layer Client-Tier Architecture Layers Sunday, July 7, 13
  • 7. Implementation What are Delegates? Could be as simple as a generic Javascript object. For example, consider an Authentication delegate with only three (3) public functions. Promises are the recommend solution in order to support the asynchronous nature of remote WebService calls. It is important to note that all Delegate public functions return Promises; since all public functions are async and will respond with real data response(s) at a future point in time Delegates are objects with public functions. Delegates are `proxies` to remote Web Services. Delegates are client-side Data Services. Sunday, July 7, 13
  • 8. (1) What are the public functions available (2) What are the arguments for each function (3) What are the data structures in the WebService responses (4) What are the errors possible from each function call Application Programming Interfaces (API) simply clarify: Implementation What are Delegate API(s)? Sunday, July 7, 13
  • 9. Implementation What are Delegate API(s)? Consumers of the AuthDelegate API can use: login( ) logout( ) loadPrivileges( ) (1) functions = login( userName, password )(2) arguments = login( ) -> { sessionID : <String> } logout( ) -> true | false loadPrivileges( ) -> { level : <int> } (3) responses = The API is now more easily understood. Sunday, July 7, 13
  • 10. Implementation How are Delegates used? Call Delegate API Call Delegate API Controllers use delegates and attach .then() handlers for responses. Note that the controller has no knowledge of how the login() or logout() methods actually work… so this delegate reference could be either a real service or a mock service! Sunday, July 7, 13
  • 11. Implementation How are Delegates used? (cont.) Call Delegate API Using Delegate API ResponsesInjected `session` model Controllers use delegates and attach handlers for responses. Notice that the LoginController has no knowledge of `how` the login() or logout() methods actually work… This means that authDelegate could be an instance of real service or a mock service; since both have the same API! Sunday, July 7, 13
  • 12. Implementation How to build a Delegate ? Use generic Javascript object to outline the API Sunday, July 7, 13
  • 13. Implementation How to build a Delegate ? Use Module Pattern and AngularJS to define authDelegate instance. NOTE: the authDelegate can then be injected into Controllers. Sunday, July 7, 13
  • 14. Implementation How to build a Mock Delegate? Step 3: Implement API methods with asynchronous, mock responses inline data construction Delay response Publish API Here we used $timeout with a 2-sec delay; to simulate an asynchronous response. Notice that we did not load any external mock data… instead we generated inline the data structures expected in the responses. Sunday, July 7, 13
  • 15. Implementation Mock Delegate using External Data? Implement API method internally using AngularJS $http to load external mock data; captured in the /data/login.json file. Load external mock data extract data structures Here $http.get() also returns a Promise. Our AuthDelegate .then() handler intercepts that response and extracts the desired data structures… This occurs before the LoginController .then() handler is notified. Sunday, July 7, 13
  • 16. Implementation Building a DataServices Library How does your architecture scale if you have 2..n Delegates? How do you separate Delegate factory/service definitions from your main application (AuthenticationDemo is shown below )? Note: Each delegate constructor function has been collapsed. Expanded you can imagine that the above approach gets `messy` VERY quickly... Question: Sunday, July 7, 13
  • 17. Implementation Building a DataServices Library 1) Define all your data services in a separate JS file. 2) Register your data services within a custom, data-service module. 3) Register your module/library as a dependent module for your main App 4) Inject Delegate instances into your Controllers Answer: MyAppDataServices.js DemoApp.js Sunday, July 7, 13
  • 18. Implementation How to package a DataServices Library AllDelegates.js Build packages Publish... - Outside of AngularJS - Sunday, July 7, 13
  • 19. Implementation How to package a DataServices Library MyAppDataServices.js- Using AngularJS - Register Constructors... Sunday, July 7, 13