SlideShare una empresa de Scribd logo
1 de 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 |

Más contenido relacionado

La actualidad más candente

patroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deploymentpatroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deploymenthyeongchae lee
 
Step By Step to Install Oracle Business Intelligence
Step By Step to Install Oracle Business IntelligenceStep By Step to Install Oracle Business Intelligence
Step By Step to Install Oracle Business IntelligenceOsama Mustafa
 
Sql 2012 always on
Sql 2012 always onSql 2012 always on
Sql 2012 always ondilip nayak
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?Mydbops
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
Grafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for PrometheusGrafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for PrometheusWeaveworks
 
Intro to HTML Elements and CSS Declarations
Intro to HTML Elements and CSS DeclarationsIntro to HTML Elements and CSS Declarations
Intro to HTML Elements and CSS DeclarationsBruce Clary
 
Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개NeoClova
 
Spring Cloud Workshop
Spring Cloud WorkshopSpring Cloud Workshop
Spring Cloud WorkshopYongSung Yoon
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterKenny Gryp
 
RxJS Operators - Real World Use Cases - AngularMix
RxJS Operators - Real World Use Cases - AngularMixRxJS Operators - Real World Use Cases - AngularMix
RxJS Operators - Real World Use Cases - AngularMixTracy Lee
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...Frank Munz
 
SQL Server High Availability Solutions (Pros & Cons)
SQL Server High Availability Solutions (Pros & Cons)SQL Server High Availability Solutions (Pros & Cons)
SQL Server High Availability Solutions (Pros & Cons)Hamid J. Fard
 
Scaling Your Web Application
Scaling Your Web ApplicationScaling Your Web Application
Scaling Your Web ApplicationKetan Deshmukh
 
Performance Testing Cloud-Based Systems
Performance Testing Cloud-Based SystemsPerformance Testing Cloud-Based Systems
Performance Testing Cloud-Based SystemsTechWell
 
AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...
AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...
AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...tbdeaharhnsgluczra
 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjsmanojbkalla
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxNeoClova
 

La actualidad más candente (20)

ProxySQL at Scale on AWS.pdf
ProxySQL at Scale on AWS.pdfProxySQL at Scale on AWS.pdf
ProxySQL at Scale on AWS.pdf
 
patroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deploymentpatroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deployment
 
Step By Step to Install Oracle Business Intelligence
Step By Step to Install Oracle Business IntelligenceStep By Step to Install Oracle Business Intelligence
Step By Step to Install Oracle Business Intelligence
 
Sql 2012 always on
Sql 2012 always onSql 2012 always on
Sql 2012 always on
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Grafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for PrometheusGrafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for Prometheus
 
Intro to HTML Elements and CSS Declarations
Intro to HTML Elements and CSS DeclarationsIntro to HTML Elements and CSS Declarations
Intro to HTML Elements and CSS Declarations
 
Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개
 
Spring Cloud Workshop
Spring Cloud WorkshopSpring Cloud Workshop
Spring Cloud Workshop
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
RxJS Operators - Real World Use Cases - AngularMix
RxJS Operators - Real World Use Cases - AngularMixRxJS Operators - Real World Use Cases - AngularMix
RxJS Operators - Real World Use Cases - AngularMix
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
 
SQL Server High Availability Solutions (Pros & Cons)
SQL Server High Availability Solutions (Pros & Cons)SQL Server High Availability Solutions (Pros & Cons)
SQL Server High Availability Solutions (Pros & Cons)
 
Scaling Your Web Application
Scaling Your Web ApplicationScaling Your Web Application
Scaling Your Web Application
 
Performance Testing Cloud-Based Systems
Performance Testing Cloud-Based SystemsPerformance Testing Cloud-Based Systems
Performance Testing Cloud-Based Systems
 
AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...
AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...
AWS Certified Solutions Architect - Associate Practice Questions Flashcards _...
 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjs
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
 

Destacado

Planificación y organización de dominio
Planificación y organización de dominioPlanificación y organización de dominio
Planificación y organización de dominiolilidani103
 
Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)Vijay Kani
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS TestingEyal Vardi
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directivesyprodev
 
AngularJS Custom Directives
AngularJS Custom DirectivesAngularJS Custom Directives
AngularJS Custom Directivesyprodev
 
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
 

Destacado (15)

Planificación y organización de dominio
Planificación y organización de dominioPlanificación y organización de dominio
Planificación y organización de dominio
 
Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)Basics of angular directive (Part - 1)
Basics of angular directive (Part - 1)
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS Testing
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directives
 
AngularJS Custom Directives
AngularJS Custom DirectivesAngularJS Custom Directives
AngularJS Custom Directives
 
Nodejs
NodejsNodejs
Nodejs
 
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
 

Similar a 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
 

Similar a 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
 

Último

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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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 |