SlideShare une entreprise Scribd logo
1  sur  64
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Web app that fits on a single web page
providing a fluid UX by loading all
necessary code with a single page load
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Navigation, history, deep linking
Persisting state
Initially loading most of its content
Download additional features as needed
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Reach Rich UX
Reduced Round Tripping
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Stands for Model-View-ViewModel
Not technology specific
Awesome with data binding!
MVVM is, foremost, a separation pattern
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Observables are special JavaScript
objects that can notify subscribers about
changes, and can automatically detect
dependencies.
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Observable Computed
Observable
Array
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<div class="console-brief" title="Go to console details">
<img data-bind="attr: { src: consoleImageName }" class="img-
polaroid"/>
<address data-bind="text:Title"></address> By <span data-
bind="text: Manufactorer"></span><br />
….
</div >
var Title = ko.observable();
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Notifies when items are added/removed
DOESN’T notify when object are changed
Compatible with standard array functions
Tracks the state of the array
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
define(['services/dataservice'], function
(dataservice) {
var games = ko.observableArray();
dataservice.getGamesPartials(games);
var vm = {
games: games,
};
});
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<section class="view-list" data-bind="foreach: games">
<article class="article-container-full-width">
<div>
<img data-bind="attr: { src: imageName }"
class="img-polaroid"/>
<span data-bind="text: Title"></span> <br />
Genre: <span data-bind="text: Genre"></span>
</div>
</article>
</section>
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Based on other properties and observables
Supports data binding
Enables creation of new observables
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
entity.finalPrice = ko.computed(function () {
return parseInt(entity.Price() * (100 -
entity.Discount()) / 100);
});
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Text and
appearance
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Dependency injection for JavaScript
Load only what we need, when we need
Uses the AMD pattern
Break your applications into smaller,
more manageable, units of code
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Module
F
Module
E
Module
A
Module
B
Module
D
Module
C
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Module
F
Module
E
Module
A
Module
B
Module
D
Module
C
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<script src="scripts/require.js"
data-main="App/main"></script>
Loading require.js
Start here – load main.js
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Loading require.jsdefine(['durandal/system',
'services/logger','durandal/plugins/router','config',
'services/datacontext'],
function (system, logger,router,config,datacontext) {
var shell = {
activate: activate,
router: router
};
return shell;
function activate() {
return
datacontext.primeData().then(boot).fail(failedInitialization);
}
...
Define the module
Dependencies
Each dependency has a
corresponding object
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
define([“jquery”
], function ($) {
return function(){};
});
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Loading require.js
Define the module
Each dependency has a
corresponding object
No more messy script tags parade
Load only what's needed, WHEN needed
Allows for nested dependencies
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Handle navigation from page to page
Handle loading of resources (JS,HTML…)
Listen for app lifecycle events
Manage views
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Routing
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
View and ViewModel composition
Dynamically load modules as needed
Fires App lifecycle events
Async programming with promises
Page navigation and deep linking
Configurable convention
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Static content
Staticcontent
Dynamic
Shell area
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
define(['durandal/system',
'services/logger'],
function (system, logger) {
var shell = {
activate:activate
};
return shell;
function activate() {
logger.log('Shell loaded!');
}
});
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<div>
<header data-bind="compose: { view:'nav'}">
</header>
<section id="content" class="main
container-fluid" data-bind="compose: { model:
router.activeItem, afterCompose:
router.afterCompose, transition: 'entrance' }">
</section>
</div>
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Configure the routes
Activate the Router object
Bind away!
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Based on the popular SammyJS framework
A singleton module – only one per app
Multiple ways to define routes
Mapping is done most to least specific
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
var router =
require('durandal/plugins/router');
router.mapRoute('consoles',
'viewmodels/consoles', 'Consoles', true);
router.mapNav('games', 'viewmodels/games',
'Games');
Requires the
router object
URL
Module Name Visible
Same as mapRoute,
but always visible.
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
var routes = [
{ url: 'consoles', moduleId:
'viewmodels/consoles', name: 'Consoles',
visible: true },
{ url: 'games', moduleId:'viewmodels/games',
name: 'Games', visible: true },
{ url: 'consoledetails/:id', moduleId:
'viewmodels/consoledetails', name: 'Console
Details', visible: false }];
Encapsulate the
routes in config file
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
define(['durandal/system',
'services/logger','durandal/plugins/router','config','services/datacon
text'],
function (system, logger,router,config,datacontext) {
var shell = {
activate: activate,
router: router
};
return shell;
function activate() {
return
datacontext.primeData().then(boot).fail(failedInitialization);
}
function boot() {
router.map(config.routes);
return router.activate(config.startModule);
}
});
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<div class="navbar-inner navbar-secondary">
<div class="btn-group" data-
bind="foreach: router.visibleRoutes">
<a data-bind="attr: { href: hash }, css:
{ active: isActive }, html: caption"
class="btn btn-info"></a>
</div>
</div>
For each visible route…
Bind the route link
Check if link is active, if
so add css class ‘active’
And its html to the
content of the link
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<div data-bind="css: { active:
router.isNavigating }" class="pull-right
loader">
<i class="icon-spinner icon-2x icon-
spin"></i>
</div>
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
navigateBack()
navigateTo(url)
replaceLocation(url)
Navigate without
saving history!
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
canActivate 
canDeactivate
Deactivate 
Activate
beforeBind 
afterBind
viewAttached
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
canActivate 
canDeactivate
Deactivate 
Activate
beforeBind 
afterBind
viewAttached
documentAtt
aced
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
No consistency in callback APIs
No guarantees whatsoever
Tying callbacks kills the flow of our code
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
 A Promise represents the result of a
task, which may or may not have
completed.
 By using promises we wont be calling a
passed callback, but instead – return a
promise.
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
getGamesForConsole("xbox360", function (err, result) {
getGamesByGenre("action", function (Err, result) {
// do more stuff here
});
});
getGamesForConsle("xbox360").then(function (result) {
return getGameByGenre(result, "action");
}).fail(failFunction);
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Only one success or failure will be called
Handles will always be called asyncly
Promises can be easily chained
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Pure JavaScript library, 8.5kb minified
Durandal make use of Q for its promises
Make it easy to write promise based code
Allows to wrap non promise based code
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
var primeData = function () {
return Q.all([getLookups(), getSpeakersPartials(null, true)]);
}
function getLookups() {
return EntityQuery.from('Lookups').using(manager).execute()
.fail(queryFailed);
}
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Durandal takes care of all the plumbing of
a SPA so you wont have to.
Works in a modular way, saves bandwidth
Uses KnockoutJS for its data binding
Fun!
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
http://durandaljs.com/documentation/
http://johnpapa.net/SPA
http://pluralsight.com/training/courses/TableOfContents?c
ourseName=single-page-apps-jumpstart
http://knockoutjs.com/documentation/introduction.html
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2
013/DEV-B350#fbid=K3XtHQDs9Q3
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |

Contenu connexe

En vedette

AngularJS custom directive
AngularJS custom directiveAngularJS custom directive
AngularJS custom directiveNascenia IT
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...FalafelSoftware
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile ProcessEyal Vardi
 
Building AngularJS Custom Directives
Building AngularJS Custom DirectivesBuilding AngularJS Custom Directives
Building AngularJS Custom DirectivesDan Wahlin
 
Node.js Spplication Scaling
Node.js Spplication ScalingNode.js Spplication Scaling
Node.js Spplication ScalingEyal Vardi
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipesEyal Vardi
 
Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)raj upadhyay
 
Getting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro AppsGetting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro AppsDan Wahlin
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 

En vedette (9)

AngularJS custom directive
AngularJS custom directiveAngularJS custom directive
AngularJS custom directive
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
Building AngularJS Custom Directives
Building AngularJS Custom DirectivesBuilding AngularJS Custom Directives
Building AngularJS Custom Directives
 
Node.js Spplication Scaling
Node.js Spplication ScalingNode.js Spplication Scaling
Node.js Spplication Scaling
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipes
 
Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)Tree Traversals (In-order, Pre-order and Post-order)
Tree Traversals (In-order, Pre-order and Post-order)
 
Getting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro AppsGetting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro Apps
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 

Similaire à Spa Architecture with Durandal and Friends

Js il 2013 breeze.js
Js il 2013 breeze.jsJs il 2013 breeze.js
Js il 2013 breeze.jsEyal Vardi
 
Ui components - js-il.com
Ui components - js-il.comUi components - js-il.com
Ui components - js-il.comEyal Vardi
 
E4D js conference responsive web design - js-il.com
E4D js conference responsive web design - js-il.comE4D js conference responsive web design - js-il.com
E4D js conference responsive web design - js-il.comEyal Vardi
 
jQuery Mobile apps - js-il.com
jQuery Mobile apps - js-il.comjQuery Mobile apps - js-il.com
jQuery Mobile apps - js-il.comEyal Vardi
 
jQuery Mobile Apps
jQuery Mobile AppsjQuery Mobile Apps
jQuery Mobile AppsDima Kuzmich
 
Developing Next-Gen Enterprise Web Application
Developing Next-Gen Enterprise Web ApplicationDeveloping Next-Gen Enterprise Web Application
Developing Next-Gen Enterprise Web ApplicationMark Gu
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceBo-Yi Wu
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsSven Wolfermann
 
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...MUG-Lyon Microsoft User Group
 
Playing with php_on_azure
Playing with php_on_azurePlaying with php_on_azure
Playing with php_on_azureCEDRIC DERUE
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web ApplicationYakov Fain
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
NextJs File Based Routing A Review
NextJs File Based Routing A ReviewNextJs File Based Routing A Review
NextJs File Based Routing A Reviewijtsrd
 
JavaScript Modules in Practice
JavaScript Modules in PracticeJavaScript Modules in Practice
JavaScript Modules in PracticeMaghdebura
 

Similaire à Spa Architecture with Durandal and Friends (20)

Js il 2013 breeze.js
Js il 2013 breeze.jsJs il 2013 breeze.js
Js il 2013 breeze.js
 
Mvvm and KnockoutJS
Mvvm and KnockoutJSMvvm and KnockoutJS
Mvvm and KnockoutJS
 
Routing in SPA
Routing in SPARouting in SPA
Routing in SPA
 
Ui components
Ui componentsUi components
Ui components
 
Ui components - js-il.com
Ui components - js-il.comUi components - js-il.com
Ui components - js-il.com
 
E4D js conference responsive web design - js-il.com
E4D js conference responsive web design - js-il.comE4D js conference responsive web design - js-il.com
E4D js conference responsive web design - js-il.com
 
jQuery Mobile apps - js-il.com
jQuery Mobile apps - js-il.comjQuery Mobile apps - js-il.com
jQuery Mobile apps - js-il.com
 
jQuery Mobile Apps
jQuery Mobile AppsjQuery Mobile Apps
jQuery Mobile Apps
 
Developing Next-Gen Enterprise Web Application
Developing Next-Gen Enterprise Web ApplicationDeveloping Next-Gen Enterprise Web Application
Developing Next-Gen Enterprise Web Application
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript Conference
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
Vaadin & Web Components
Vaadin & Web ComponentsVaadin & Web Components
Vaadin & Web Components
 
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
 
Playing with php_on_azure
Playing with php_on_azurePlaying with php_on_azure
Playing with php_on_azure
 
Sails.js Intro
Sails.js IntroSails.js Intro
Sails.js Intro
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
NextJs File Based Routing A Review
NextJs File Based Routing A ReviewNextJs File Based Routing A Review
NextJs File Based Routing A Review
 
JavaScript Modules in Practice
JavaScript Modules in PracticeJavaScript Modules in Practice
JavaScript Modules in Practice
 

Dernier

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Dernier (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Spa Architecture with Durandal and Friends

  • 1. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Israel JavaScript Conference
  • 2. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 3. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 4. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Web app that fits on a single web page providing a fluid UX by loading all necessary code with a single page load
  • 5. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Navigation, history, deep linking Persisting state Initially loading most of its content Download additional features as needed
  • 6. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Reach Rich UX Reduced Round Tripping
  • 7. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 8. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 9. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 10. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 11. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Stands for Model-View-ViewModel Not technology specific Awesome with data binding! MVVM is, foremost, a separation pattern
  • 12. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 13. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 14. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Observables are special JavaScript objects that can notify subscribers about changes, and can automatically detect dependencies.
  • 15. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Observable Computed Observable Array
  • 16. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | <div class="console-brief" title="Go to console details"> <img data-bind="attr: { src: consoleImageName }" class="img- polaroid"/> <address data-bind="text:Title"></address> By <span data- bind="text: Manufactorer"></span><br /> …. </div > var Title = ko.observable();
  • 17. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Notifies when items are added/removed DOESN’T notify when object are changed Compatible with standard array functions Tracks the state of the array
  • 18. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | define(['services/dataservice'], function (dataservice) { var games = ko.observableArray(); dataservice.getGamesPartials(games); var vm = { games: games, }; });
  • 19. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | <section class="view-list" data-bind="foreach: games"> <article class="article-container-full-width"> <div> <img data-bind="attr: { src: imageName }" class="img-polaroid"/> <span data-bind="text: Title"></span> <br /> Genre: <span data-bind="text: Genre"></span> </div> </article> </section>
  • 20. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Based on other properties and observables Supports data binding Enables creation of new observables
  • 21. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | entity.finalPrice = ko.computed(function () { return parseInt(entity.Price() * (100 - entity.Discount()) / 100); });
  • 22. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Text and appearance
  • 23. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 24. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 25. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 26. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Dependency injection for JavaScript Load only what we need, when we need Uses the AMD pattern Break your applications into smaller, more manageable, units of code
  • 27. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Module F Module E Module A Module B Module D Module C
  • 28. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Module F Module E Module A Module B Module D Module C
  • 29. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | <script src="scripts/require.js" data-main="App/main"></script> Loading require.js Start here – load main.js
  • 30. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Loading require.jsdefine(['durandal/system', 'services/logger','durandal/plugins/router','config', 'services/datacontext'], function (system, logger,router,config,datacontext) { var shell = { activate: activate, router: router }; return shell; function activate() { return datacontext.primeData().then(boot).fail(failedInitialization); } ... Define the module Dependencies Each dependency has a corresponding object
  • 31. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | define([“jquery” ], function ($) { return function(){}; });
  • 32. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Loading require.js Define the module Each dependency has a corresponding object No more messy script tags parade Load only what's needed, WHEN needed Allows for nested dependencies
  • 33. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 34. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 35. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Handle navigation from page to page Handle loading of resources (JS,HTML…) Listen for app lifecycle events Manage views
  • 36. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Routing
  • 37. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | View and ViewModel composition Dynamically load modules as needed Fires App lifecycle events Async programming with promises Page navigation and deep linking Configurable convention
  • 38. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Static content Staticcontent Dynamic Shell area
  • 39. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | define(['durandal/system', 'services/logger'], function (system, logger) { var shell = { activate:activate }; return shell; function activate() { logger.log('Shell loaded!'); } });
  • 40. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | <div> <header data-bind="compose: { view:'nav'}"> </header> <section id="content" class="main container-fluid" data-bind="compose: { model: router.activeItem, afterCompose: router.afterCompose, transition: 'entrance' }"> </section> </div>
  • 41. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 42. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Configure the routes Activate the Router object Bind away!
  • 43. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Based on the popular SammyJS framework A singleton module – only one per app Multiple ways to define routes Mapping is done most to least specific
  • 44. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | var router = require('durandal/plugins/router'); router.mapRoute('consoles', 'viewmodels/consoles', 'Consoles', true); router.mapNav('games', 'viewmodels/games', 'Games'); Requires the router object URL Module Name Visible Same as mapRoute, but always visible.
  • 45. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | var routes = [ { url: 'consoles', moduleId: 'viewmodels/consoles', name: 'Consoles', visible: true }, { url: 'games', moduleId:'viewmodels/games', name: 'Games', visible: true }, { url: 'consoledetails/:id', moduleId: 'viewmodels/consoledetails', name: 'Console Details', visible: false }]; Encapsulate the routes in config file
  • 46. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | define(['durandal/system', 'services/logger','durandal/plugins/router','config','services/datacon text'], function (system, logger,router,config,datacontext) { var shell = { activate: activate, router: router }; return shell; function activate() { return datacontext.primeData().then(boot).fail(failedInitialization); } function boot() { router.map(config.routes); return router.activate(config.startModule); } });
  • 47. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | <div class="navbar-inner navbar-secondary"> <div class="btn-group" data- bind="foreach: router.visibleRoutes"> <a data-bind="attr: { href: hash }, css: { active: isActive }, html: caption" class="btn btn-info"></a> </div> </div> For each visible route… Bind the route link Check if link is active, if so add css class ‘active’ And its html to the content of the link
  • 48. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | <div data-bind="css: { active: router.isNavigating }" class="pull-right loader"> <i class="icon-spinner icon-2x icon- spin"></i> </div>
  • 49. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | navigateBack() navigateTo(url) replaceLocation(url) Navigate without saving history!
  • 50. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 51. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | canActivate canDeactivate Deactivate Activate beforeBind afterBind viewAttached
  • 52. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | canActivate canDeactivate Deactivate Activate beforeBind afterBind viewAttached documentAtt aced
  • 53. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 54. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | No consistency in callback APIs No guarantees whatsoever Tying callbacks kills the flow of our code
  • 55. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |  A Promise represents the result of a task, which may or may not have completed.  By using promises we wont be calling a passed callback, but instead – return a promise.
  • 56. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | getGamesForConsole("xbox360", function (err, result) { getGamesByGenre("action", function (Err, result) { // do more stuff here }); }); getGamesForConsle("xbox360").then(function (result) { return getGameByGenre(result, "action"); }).fail(failFunction);
  • 57. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Only one success or failure will be called Handles will always be called asyncly Promises can be easily chained
  • 58. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Pure JavaScript library, 8.5kb minified Durandal make use of Q for its promises Make it easy to write promise based code Allows to wrap non promise based code
  • 59. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | var primeData = function () { return Q.all([getLookups(), getSpeakersPartials(null, true)]); } function getLookups() { return EntityQuery.from('Lookups').using(manager).execute() .fail(queryFailed); }
  • 60. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | Durandal takes care of all the plumbing of a SPA so you wont have to. Works in a modular way, saves bandwidth Uses KnockoutJS for its data binding Fun!
  • 61. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com | http://durandaljs.com/documentation/ http://johnpapa.net/SPA http://pluralsight.com/training/courses/TableOfContents?c ourseName=single-page-apps-jumpstart http://knockoutjs.com/documentation/introduction.html http://channel9.msdn.com/Events/TechEd/NorthAmerica/2 013/DEV-B350#fbid=K3XtHQDs9Q3
  • 62. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 63. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
  • 64. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |