42
Durandal Peter Morlion

Durandal at Team4Talent

Embed Size (px)

DESCRIPTION

A presentation (in Dutch) on using Durandal for SPAs. This was a presentation given for an internal meeting at Team4Talent (http://www.team4talent.be). There is a demo app to go along with it at https://github.com/petermorlion/DurandalDemo. The notes with each slide sometimes refer to this demo app.

Citation preview

Page 1: Durandal at Team4Talent

Durandal

Peter Morlion

Page 2: Durandal at Team4Talent

Wat?

• Framework voor SPA• Wat is een SPA?

Page 3: Durandal at Team4Talent

Drie hoofdbrokken

• jQuery• RequireJS• Knockout

Page 4: Durandal at Team4Talent

jQuery

Page 5: Durandal at Team4Talent

RequireJS

Page 6: Durandal at Team4Talent

RequireJS: wat?

• AMD• Javascript ==(=) javashit ?• Dependency injection

Page 7: Durandal at Team4Talent

RequireJS modules: simpel object (singleton!)

Page 8: Durandal at Team4Talent

RequireJS modules: met dependencies• Array met module ids• Function• RequireJS lost dependencies op

Page 9: Durandal at Team4Talent

RequireJS modules: singelton vermijden• return function

Page 10: Durandal at Team4Talent

RequireJS: require

Page 11: Durandal at Team4Talent

RequireJS: configuration

• Paths• Shim

Page 12: Durandal at Team4Talent

Knockout

Page 13: Durandal at Team4Talent

Knockout: wat?

• javascript MVVM

Model

ViewModel

View

Magic

Jouw code (of mapping plugin)

Page 14: Durandal at Team4Talent

Knockout: HTML

• Databinding

• Gewoon javascript mag

• Meerdere properties

Page 15: Durandal at Team4Talent

Knockout: viewmodels

• Observables zijn functions:

Page 16: Durandal at Team4Talent

Knockout: HTML + viewmodels

• Of:

Page 17: Durandal at Team4Talent

Knockout: observables

Page 18: Durandal at Team4Talent

Knockout: computed

Page 19: Durandal at Team4Talent

Knockout: subscribe

Page 20: Durandal at Team4Talent

Knockout: bindings

visibletexthtmlcssstyle

attrforeachififnotwith

clickeventsubmitenabledisablevaluehasFocuscheckedoptionsselectedOptionsuniqueNametemplate

Page 21: Durandal at Team4Talent

Knockout: customBindings

Page 22: Durandal at Team4Talent

Knockout: binding contexts

• $data• $parent• $parents• $root• $index

Page 23: Durandal at Team4Talent

Knockout: data

• ko.toJS(viewModel)• ko.toJSON(viewModel)

• Knockout mapping plugin:• ko.mapping.fromJS• ko.mapping.updateFromJS• ko.mapping.toJS• ko.mapping.toJSON• ko.mapping.fromJSON

Page 24: Durandal at Team4Talent

Knockout: containerless syntax

Page 25: Durandal at Team4Talent

Durandal

Page 26: Durandal at Team4Talent

Durandal: modules

• AMD modules met RequireJS• Iedere module krijgt een eigen id

Page 27: Durandal at Team4Talent

Durandal: views

• Gewoon html bestand• Slechts 1 root element• Databinding (Knockout!) verbindt view met module

Page 28: Durandal at Team4Talent

Durandal: views en viewmodels

• Convention:• viewmodels/customerList.js• views/customerList.html

Page 29: Durandal at Team4Talent

Durandal: composition

• Object composition• Visual composition

Page 30: Durandal at Team4Talent

Durandal: visual composition

Page 31: Durandal at Team4Talent

Durandal: composition extras

• strategy• transition• cacheViews• activate• preserveContext, area, activationData, mode, hooks, whoa!• composition lifecycle: getView, activate, binding, bindingComplete,

attached, compositionComplete, detached

Page 32: Durandal at Team4Talent

Durandal: debugging

• Veel info in console

• Cache busting

Page 33: Durandal at Team4Talent

Durandal: dialogs

• app.showMessage en app.showDialog

Page 34: Durandal at Team4Talent

Durandal: app setup 1

Page 35: Durandal at Team4Talent

Durandal: app setup 2

Page 36: Durandal at Team4Talent

Durandal: app setup 3

Page 37: Durandal at Team4Talent

Durandal: plugins

• http en serializer • observable• …

Page 38: Durandal at Team4Talent

Durandal: main.js

• Configuratie van RequireJS en Durandal• Andere libraries:• Vóór RequireJS• Via RequireJS

Page 39: Durandal at Team4Talent

Durandal en ASP.NET MVC

• HotTowel template

Page 40: Durandal at Team4Talent

Durandal: nog veel meer

• Publish-subscribe• Templatable widgets• Child routers• Custom project structuur (in plaats van /views/ en /viewModels/)• Custom manier om moduleId toe te kennen en op te halen• Custom manier om modules aan te maken• system.guid()• Custom manier om views te vinden• Builden met NodeJS en Weyland (lint, minify, combine,…)• Builden met NodeJS en Weyland vanuit Visual Studio• Builden met Mimosa• SEO mogelijkheden• Integreer Q, Dojo, KendoUI, Almond, i18next,…• PhoneGap, Node-Webkit, Windows 8

Page 41: Durandal at Team4Talent

En verder

• http://jquery.com/• http://requirejs.org/• http://knockoutjs.com/

• http://durandaljs.com/

Page 42: Durandal at Team4Talent

Einde

Hmm, javascript ain’t so bad after all