SlideShare a Scribd company logo
Building Single Page Apps
with DurandalJS
@kennethtruyers
www.kenneth-truyers.net
What is a Single Page App?
Web app that fits on a single page. It provides
fluent UX by loading all necessary data on
page load and then fetch progressively
Why should I build a SPA?
• Reach
• Devices, platforms, browsers
• Rich user experience
• Fluent pages through client-side navigation
• Reduced round tripping
Common traits
• Deep client-side linking
• Load what’s needed on page-load
• Progressively download when required
• Easy state maintenance
Demo: application overview
Presenting DurandalJS
AMD (Module loading) Data binding
DOM manipulation
Architecture
Client Server
REST
CSS
RequireJS Knockout jQuery Bootstrap
Views (HTML)ViewModels (JS)
Durandal
…
Demo: application code
Key concepts
• Modularization
• Routing
• Binding
• Composition
• Lifecycle & Promises
Modularization with RequireJS
define(['jquery', 'knockout'],
function ($, ko) {
var loaddata = function() {
$.ajax( ...);
};
var name = "myname";
return {
activate: loaddata,
name: name
};
});
AMD wrap
Dependencies
Private
Public interface
Demo: Modularization
Routing
• Client-side routing
• Deep linking
• URL parameters
• Route configuration
Demo: routing
Binding with Knockout
• Three binding types
• Simple properties
• ObservableArrays
• Computed
Demo: binding
Composition
• Object composition
• RequireJS and Module loading
• Visual composition
• Durandal feature
• Compose views + viewmodels inside other views
Demo: Composition
Lifecycle & promises
• Every page has “hooks” we can use to control behavior
• Lifecycle:
• Deactivation
• Activation
• Binding
• Composition
Lifecycle & promises
• Deactivation
• canDeactivate()
• deactivate()
• Activation
• canActivate()
• activate()
• Binding
• binding()
• bindingComplete()
• Composition
• attached()
• compositionComplete()
• detached()
Demo: Lifecycle & promises
Durandal: overview
• Modularization
• Routing
• Binding
• Composition
• Lifecycle & Promises
The future of Durandal
• Durandal + Angular  Merge into Angular 2.0
• Bringing strong suits of each framework together
Durandal + Angular merge
• Durandal
• Standardized module system
• Lifecycle & promises
• Composition
• Angular
• Web components through (improved)
directives
• Databinding
• Routing
• ES6 + modern browser
• Non backward-compatible
How to get it?
• Nuget
• Install-Package durandal
• Bower
• bower install durandal
• Mimosa
• mimosa skel:new durandal
• Raw downloads:
• durandaljs.com
• github.com/bluespire/durandal
• Visual Studio gallery: visualstudiogallery.msdn.microsoft.com
Links
• Demo application
• github.com/Kennethtruyers/DurandalDemos
• Docs & downloads
• durandaljs.com
• GitHub
• github.com/BlueSpire/Durandal
• Support
• Stackoverflow
• groups.google.com/forum/#!forum/durandaljs
Q & A

More Related Content

PDF
Calculating the Credit Equivalent Amount of Derivatives Products for the UAE ...
PPTX
Computer vision syndrome (Digital eyestrain)
PPT
JNTERPRETATION OF SINGLE FIELD PRINTOUT FROM HUMPHREY'S
PPTX
Intraocular pressure presentation slideshare
PDF
Eye Diseases
PPTX
Ocular blood flow in glaucoma
PPTX
Uveitis quiz (masquerade syndrome)
PPTX
HYPERTENSIVE RETINOPATHY.pptx
Calculating the Credit Equivalent Amount of Derivatives Products for the UAE ...
Computer vision syndrome (Digital eyestrain)
JNTERPRETATION OF SINGLE FIELD PRINTOUT FROM HUMPHREY'S
Intraocular pressure presentation slideshare
Eye Diseases
Ocular blood flow in glaucoma
Uveitis quiz (masquerade syndrome)
HYPERTENSIVE RETINOPATHY.pptx

Similar to Building single page apps with Durandal js (20)

PPTX
Real World Single Page App - A Knockout Case Study
PPTX
Canopy view of single-page applications (SPAs)
PPTX
Building mvvm & single pageapps in js
DOCX
Single Page Application
PPTX
Benefits of developing single page web applications using angular js
PPTX
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
PPTX
WebNetConf 2012 - Single Page Apps
PPTX
Single Page Applications: Your Browser is the OS!
PPTX
Building modular single page applications
PPTX
Angular jS Introduction by Google
 
KEY
Sugarcoating your frontend one ViewModel at a time
PPTX
Making Single Page Applications (SPA) faster
PPTX
Velocity spa faster_092116
PPTX
Single page applications
PPTX
e-suap - client technologies- english version
PPTX
CodeCon DurandalJS
PDF
ASP.NET - Architecting single page applications with knockout.js
PPTX
Single Page Applications on JavaScript and ASP.NET MVC4
PDF
Single Page Application (SPA): A Comprehensive Guide for Beginners
PPTX
Spa Architecture with Durandal and Friends
Real World Single Page App - A Knockout Case Study
Canopy view of single-page applications (SPAs)
Building mvvm & single pageapps in js
Single Page Application
Benefits of developing single page web applications using angular js
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
WebNetConf 2012 - Single Page Apps
Single Page Applications: Your Browser is the OS!
Building modular single page applications
Angular jS Introduction by Google
 
Sugarcoating your frontend one ViewModel at a time
Making Single Page Applications (SPA) faster
Velocity spa faster_092116
Single page applications
e-suap - client technologies- english version
CodeCon DurandalJS
ASP.NET - Architecting single page applications with knockout.js
Single Page Applications on JavaScript and ASP.NET MVC4
Single Page Application (SPA): A Comprehensive Guide for Beginners
Spa Architecture with Durandal and Friends
Ad

Recently uploaded (20)

PDF
August Patch Tuesday
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Encapsulation theory and applications.pdf
PDF
Getting Started with Data Integration: FME Form 101
PPTX
A Presentation on Touch Screen Technology
PPTX
Tartificialntelligence_presentation.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
project resource management chapter-09.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Hybrid model detection and classification of lung cancer
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
August Patch Tuesday
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 5: Probability Theory and Statistics
Encapsulation theory and applications.pdf
Getting Started with Data Integration: FME Form 101
A Presentation on Touch Screen Technology
Tartificialntelligence_presentation.pptx
DP Operators-handbook-extract for the Mautical Institute
project resource management chapter-09.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
1 - Historical Antecedents, Social Consideration.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Hybrid model detection and classification of lung cancer
Hindi spoken digit analysis for native and non-native speakers
A novel scalable deep ensemble learning framework for big data classification...
1. Introduction to Computer Programming.pptx
Assigned Numbers - 2025 - Bluetooth® Document
WOOl fibre morphology and structure.pdf for textiles
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Ad

Building single page apps with Durandal js

Editor's Notes

  • #2: Who has built a SPA?What frameworks are we using?
  • #3: Single pages apps is a bad nameMeans single server loadMultiple client side pages (or screens)UX is all on the clientNot business, not security
  • #5: For a web app, traditional server side does not make sense anymoreThink of it as an app more then a web siteExample: phone application which fetches screens instead of data from an API
  • #6: Demo 1:Show simple applicationShow page logsShow network traffic
  • #8: Durandal is a framework of frameworksCoordinates different partsServer agnosticRest or XML or …
  • #9: Show code Views & ViewModelsShell
  • #10: ModularizationFixing JS “global”RoutingDeep linkingBackward navigationBindingSolving DOM manipulationCompositionObject & view composition, user controls, …Lifecycle & promisesLike an app  asynchronous hooks
  • #11: Information hiding (global)SOLID:Separation of concernsSingle responsibilityInversion of controlTesting: easy mockingOne module per file
  • #12: Show how pages are separated by requireJSmodulesShow how pages get loaded incrementallyNot only views, also modulesShow module configurationsAdd toastr to projectdetails.
  • #13: Fluid navigationSharing URL’s, bookmarking
  • #14: Get changeset “Added Toastr to projectdetail”Show deep linkingShow route configurationShow route binding in shellAdd about pageGet changeset “Include detail page”Add contributors detail
  • #15: Solving DOM access problemsDeclarative mark-up
  • #16: Get changeset “Added routing for contributor detail page”Show simple data binding on About Page (title)Add valueupdate: ‘afterkeydown’Get changeset “Added simple observable”Show Computed on contributor detail (firstname + lastname)View: col-xs-10  form  label, input[data-bind=value: FirstName]ViewModel: Include observable pluginobservable.defineProperty(self, 'FullName', function() { return self.contributor.FirstName + ' ' + self.contributor.LastName;});Get changeset “added computed observable”Show observable array on projects pageView: <a href="#" data-bind="click: $parent.removeProject">Remove</a>ViewModel:self.removeProject = function(project) {self.projects.remove(project);};
  • #18: Show shellGet changeset “Added composition module”Show adding user control inside project detail(emptyContrib)(contribList)Show how this can be done by observing the name variable observable(viewModel, 'firstName').subscribe(function(value){ });
  • #21: Show activation promise in projects.jsShow example withsetTimeoutShow cancelling page navigation in projectdetail.jsShow returning true / falseShow returning promise Require ‘plugins/dialog’self.canDeactivate = function() { return dialog.showMessage("Are you sure?", "Do you want to leave?", ["Yes", "No"]); };
  • #22: ModularizationFixing global issuesRoutingDeep linkingBackward navigationBindingSolving DOM manipulationSeparation of logic / viewsCompositionObject & view composition, user controls, …Lifecycle & promisesLike an app  asynchronous hooks
  • #24: If you need to choose now: Durandal or Angular  does not matter since they will both have an upgrade path to Angular 2.0