Codes d'exemple
Vous retrouverez dans cette archives certains codes d'exemple issus du livre "Développement et architecture des Applications Web Modernes" édité en 2021 aux éditions ENI.
Les mini-projets de démonstration sont présentés par chapitre dans la liste ci-dessous. Cliquez sur le lien pour tester un projet dans votre navigateur.
La liste complète de fichiers source utilisés dans
le livre est donnée par ordre d'apparition.
Cliquez sur la flèche à gauche du nom de chaque
mini-projet pour faire apparaître le chemin vers
tous les fichiers (partant du dossier
src/). Le hash tag en fin de chemin
indique la région du fichier présentée dans le
livre (#region <clef>).
Ressources en ligne
Cette archive ne contient qu'une partie des codes d'exemple utilisés dans le livre, certains pouvant être trop complexes ou volumineux. Par ailleurs, ceux-ci ne recevront pas ou peu de mises-à-jour, afin de rester précisément conformes au contenu imprimé.
Pour consulter l'ensemble du code ainsi que des contenus complémentaires, rendez-vous sur fullweb.dev.
Chapitre 3 : Adopter une approche par
composants
1. Introduction à la programmation par composant
1.5 Les limites initiales du développement Web
Simples examples
- CBSE/introduction/prototype.js
- CBSE/introduction/class.js
2. Premières fondations pour le Web
2.1 Plug-ins
Plugin JQuery (slider)
- CBSE/jquery/slider-plugin.js#add-function
- CBSE/jquery/slider.html#css
- CBSE/jquery/slider.html#scripts
- CBSE/jquery/slider.html#html
- CBSE/jquery/slider.html#run
- CBSE/jquery/result.html
2.3 Cas d'étude : AngularJS
v1.0 - directive
- CBSE/angularjs/directive/hello-world.html#input
- CBSE/angularjs/directive/hello-world.html#rendering
- CBSE/angularjs/directive/hello-world.js#directive
- CBSE/angularjs/directive/hello-world.html#directive
- CBSE/angularjs/directive/hello-world.js#template
v1.2 - controllerAs
- CBSE/angularjs/controller-as/hello-world.js#controllerAs
- CBSE/angularjs/controller-as/hello-world.js#scope
- CBSE/angularjs/controller-as/hello-world.html#controller
- CBSE/angularjs/controller-as/hello-world.js#controller
v1.3 - bindToController
- CBSE/angularjs/bindtocontroller/hello-world.js#directive
v1.5+ - component helper
- CBSE/angularjs/component-helper/hello-world.js#component
3. Liens avec une approche fonctionnelle
3.2 Approche générale
React sans JSX
Hello World
- CBSE/react/hello-world.js#function
composition
- CBSE/react/composition.js#components
props
Modifiez le projet pour tester tous les exemples
- CBSE/react/composition-props.js#components
- CBSE/react/composition-props.js#render
3.3 Représenter HTML dans JavaScript
React avec JSX
Hello World
- CBSE/react/hello-jsx.jsx#component
- CBSE/react/hello-jsx.jsx#rendering
- CBSE/react/hello-jsx.js
Exemple de fonction non-pure
- CBSE/react/composition-props.js#not-pure
3.4 Le problème du rendering
fonction composant
Hello World
- CBSE/function/hello-world.js#render-fn
- CBSE/function/hello-world.js#hello-world
- CBSE/function/hello-world.js#render-hello-world
Mise à jour via des paramètres (mauvaise pratique)
- CBSE/function/components/Home.mjs#home
- CBSE/function/components/SayHello.mjs#say-hello
- CBSE/function/bad-update.mjs#render
- CBSE/function/bad-update.mjs#update
Mise à jour via des paramètres (non pure)
- CBSE/function/params.mjs#update
Avec lit-html
- CBSE/function/with-lit-html.mjs#import
- CBSE/function/with-lit-html.mjs#say-hello
- CBSE/function/with-lit-html.mjs#home
- CBSE/function/with-lit-html.mjs#render
3.5 Le problème de la gestion d'état
Composants React (props)
Modifiez le projet pour tester tous les exemples
- CBSE/react/composition-props.js#class
- CBSE/react/composition-props.js#function
- CBSE/react/composition-props.js#render-class
- CBSE/react/hello-world-class-fn.js
Composant React Stateful
-
class Increment(exemple embarqué) - CBSE/react/stateful-class.jsx#handle-click
- CBSE/react/stateful-class.jsx#render
- CBSE/react/stateful-class.jsx#dom-render
- CBSE/react/stateful-class.jsx#constructor
- CBSE/react/stateful-class.jsx#component
3.6 Vers un langage fonctionnel ?
Hooks
Inspiré d'une démo créée par Dan Abramov
- CBSE/react/stateful-hooks.jsx#component
- CBSE/react/responsive-component/useWindowWidth.js
- CBSE/react/responsive-component/MyResponsiveComponent.jsx#component
4. Naissance d'un standard
4.1 Les prédécesseurs
JSF
- CBSE/jsf/resources/fullwebdev/register.xhtml#html
- CBSE/jsf/default.xhtml#html
4.3 Introduction aux Web Components
Module
- exemple HTML embarqué
- exemple JS embarqué
Chapitre 4 : Faire bon usage des Web
Components
2. Étendre le vocabulaire HTML
2.1 Définir un élément personnalisé
Élément personnalisé autonome (Hello World)
- web-components/custom-elements/autonomous/hello-world.html#custom-element
Élément intégré personnalisé (Hello World)
- web-components/custom-elements/customized-built-in/hello-world.html#custom-element
Élément personnalisé autonome (define)
- web-components/custom-elements/autonomous/hello-world.js#define
Élément intégré personnalisé (define)
- web-components/custom-elements/customized-built-in/hello-world.js#define
2.3 Utiliser un nom valide
Validité des noms
- web-components/custom-elements/names/index.js#PotentialCustomElementName
- web-components/custom-elements/names/workaround-emoji.js
2.4 Créer une classe
Classes vides
- web-components/custom-elements/empty.component.js#class
- web-components/custom-elements/customized-built-in/hello-world.js#empty-component
- web-components/custom-elements/empty.component.js#function
2.5 Afficher un message
Élément personnalisé autonome (innerHTML)
- web-components/custom-elements/hello-world.component.js#class
- web-components/custom-elements/life-cycle/index.html#descriptive
2.6 Créer un élément personnalisé programmatiquement
Appeler le constructeur avant la définition de l'élément personnalisé
- web-components/custom-elements/life-cycle/before-define/index.js#define
- web-components/custom-elements/life-cycle/before-define/before-define.js#createElement
- web-components/custom-elements/life-cycle/before-define/before-define.js#append
- web-components/custom-elements/life-cycle/before-define/index.html#scripts
- web-components/custom-elements/life-cycle/before-define/before-define.js#DOMContentLoaded
- web-components/custom-elements/life-cycle/before-define/before-define.js#whenDefined
- logs (embarqués)
Appeler le constructeur après la définition de l'élément personnalisé
- web-components/custom-elements/life-cycle/after-define/index.js#createElement
- logs (embarqués)
2.7 Cycle de vie
connectedCallback
- web-components/custom-elements/life-cycle/connected/hello-world.component.js#connectedCallback
- web-components/custom-elements/life-cycle/connected/index.js#createConnectedElement
- web-components/custom-elements/life-cycle/connected/hello-world.component.js#disconnectedCallback
- web-components/custom-elements/life-cycle/good-hello-world.component.js#class
2.8 Support
chargement des polyfills
- web-components/custom-elements/load-polyfil.js
3. Créer et utiliser un arbre fantôme
3.1 Notions fondamentales
Associer un arbre fantôme à un élément (attachShadow)
- web-components/shadow-dom/attach/index.js#attach-element
- web-components/shadow-dom/attach/index.js#element-append
- web-components/shadow-dom/attach/index.css
- web-components/shadow-dom/attach/index.html#content
3.2 light DOM et shadow DOM
avec un élément personnalisé
- web-components/shadow-dom/attach/index.js#custom-element
- web-components/shadow-dom/attach/index.html#custom-element
Ajouter un élément (Light / Shadow DOM)
- web-components/shadow-dom/access/bases/index.js#append-to-component
- ```js
- ```
- web-components/shadow-dom/access/bases/index.js#append-to-open-shadow
3.3 Restreindre l'accès au shadom DOM
définir un arbre fantome fermé
- web-components/shadow-dom/access/bases/index.js#closed-constructor
- web-components/shadow-dom/access/bases/index.js#append-to-closed-shadow
- web-components/shadow-dom/access/bases/index.js#add-text
- web-components/shadow-dom/access/bases/index.js#use-add-text
- web-components/shadow-dom/access/bases/index.js#append-long-text
restreindre l'accès via un attribut privé
- web-components/shadow-dom/access/workaround/private-field/index.js#el-with-private-field
- web-components/shadow-dom/access/workaround/private-field/syntax-error-private.js#append
utiliser une WeakMap
- web-components/shadow-dom/access/workaround/weak/index.js#el-in-block
- web-components/shadow-dom/access/workaround/weak/index.js#workaround
- web-components/shadow-dom/access/workaround/weak/index.js#append
4. Définir le style d'un Web Component
élément <style>
- web-components/shadow-dom/attach/index.js#styled
- web-components/shadow-dom/attach/index.html#styled
4.1 Style externe
style externe
- web-components/shadow-dom/attach/index.js#ext-styled
- web-components/shadow-dom/attach/index.html#preload-css
partage de style
- web-components/shadow-dom/style/shared/demo-component-lib/common-style.js
- web-components/shadow-dom/style/shared/demo-component-lib/hello.component.js
- web-components/shadow-dom/style/shared/demo-component-lib/index.js
- web-components/shadow-dom/style/shared/demo-component-lib/bye.component.js
Constructable Stylesheet
- web-components/shadow-dom/style/constructable/demo-component-lib/common-style.js
- web-components/shadow-dom/style/constructable/demo-component-lib/hello.component.js
- web-components/shadow-dom/style/constructable/demo-component-lib/bye.component.js
4.3 Style par défaut de l'élément hôte
Style par défaut de l'élément hôte
- web-components/shadow-dom/style/host/index.js#constructor
- exemple javascript (embarqué)
- web-components/shadow-dom/style/host/index.html#content
- web-components/shadow-dom/style/host/index.css#body
- web-components/shadow-dom/style/host/index.css#in-main
4.4 Contexte
Contexte
- web-components/shadow-dom/style/context/component.css#host-context
- web-components/shadow-dom/style/context/component.css#host-fn
- web-components/shadow-dom/style/context/index.html#title
4.5 Customisation
Propriétés CSS personnalisées
- web-components/shadow-dom/style/custom-props/component.css#text-color
- web-components/shadow-dom/style/custom-props/index.css#random-text-color
- web-components/shadow-dom/style/custom-props/component.css#span-color
- web-components/shadow-dom/style/custom-props/index.css#body-text-color
5. Templates & Composition
5.1 <template>
Template : principes de base
- web-components/template/basics/index.html#template
- web-components/template/basics/index.js#component
définition programmatique d'un Template
- web-components/template/prog/index.js#template
5.2 <slot> et composition
principe
- exemple html (embarqué)
- exemple html (embarqué)
Slots : principes de base
- web-components/slot/basics/index.html#content
- web-components/slot/basics/index.js#template
- web-components/slot/basics/flat.fake.html
5.3 Slots nommés
Slots nommés
- web-components/slot/named/index.html#multiple
- web-components/slot/named/index.js#template
- web-components/slot/named/flat.fake.html#multiple
6. Attributs et propriétés
Principes de base
6.2 Mise en place d’un Web Component de démonstration
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#constructor
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#privateFields
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#render
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#connectedCallback
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#getRandomText
6.3 Exposer l’état du composant
- web-components/custom-elements/attrs-and-props/basics/index.js#getLengthHack
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#getText
- web-components/custom-elements/attrs-and-props/basics/index.js#getLength
6.4 Effectuer des actions simples
- web-components/custom-elements/attrs-and-props/basics/random-text.component.js#newText
- web-components/custom-elements/attrs-and-props/basics/index.html#new-text-button
- web-components/custom-elements/attrs-and-props/basics/index.js#newText
Gestion des propriétés
4.6.5 - Récupérer des valeurs primitives
- web-components/custom-elements/attrs-and-props/attribute/index.html#random-text
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#positiveIntOrNull
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#get-length
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#repeatOrCutToLength
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#get-text
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#render
4.6.6 - Réagir aux changements de valeur d'un attribut
- web-components/custom-elements/attrs-and-props/attribute/index.html#length
- web-components/custom-elements/attrs-and-props/attribute/index.js#newLength
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#observedAttributes
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#attributeChangedCallback
- web-components/custom-elements/attrs-and-props/attribute/index.js#newLengthProp
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#set-length
4.6.7 - Manipuler des valeurs non-primitives
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#possible-texts
- web-components/custom-elements/attrs-and-props/attribute/index.js#setPossibleTexts
4.6.8 - Propriétés lazy loadées
- web-components/custom-elements/attrs-and-props/attribute/index.html#scripts
- web-components/custom-elements/attrs-and-props/attribute/pre.js#all
- web-components/custom-elements/attrs-and-props/attribute/pre.js#set-props
- web-components/custom-elements/attrs-and-props/attribute/random-text.component.js#lazyProp
Chapitre 5 : Développer une application
monopage
Dans ce chapitre, nous construisons pas à pas différentes applications monopage minimalistes. Pour assurer la cohérence de l'ensemble, celle-ci utilisent intensivement des ES Modules, chaque étape faisant appel à des modules définits dans les étapes précédentes.
Pour accéder directement à certaines routes de ces applications, il vous sera nécessaire de lancer localement un serveur HTTP, comme évoqué dans la section "3.6 Réécriture des URL côté serveur".
1. Structure et objectifs
1.3 Architecture
Fondamentaux
- minimal-spa/1-fundamentals/index.html#main
- minimal-spa/1-fundamentals/fetch.js#getPostData
- minimal-spa/1-fundamentals/rendering.js#render
- minimal-spa/1-fundamentals/index.html#header
- minimal-spa/1-fundamentals/index.js#show
3. Manipuler l'URL du document
3.1 L'interface Location
Location API
- minimal-spa/2-location/ie-location.js
- minimal-spa/2-location/url.js#update-url
- minimal-spa/2-location/index.js#show
3.2 Utiliser l'identificateur de fragment de l'URL
Hash Routing : mise à jour du chemin
- minimal-spa/3-hashroute/path.js#updatePath
- minimal-spa/3-hashroute/update/index.js#show
3.3 Hash et historique
Hash Routing : remplacement du chemin
- minimal-spa/3-hashroute/path.js#replacePath
- minimal-spa/3-hashroute/replace/index.js#show
3.4 L'interface History
History API
- minimal-spa/4-history-api/path.js#updatePath
- minimal-spa/4-history-api/path.js#replacePath
- (embarqué) html
- minimal-spa/4-history-api/base-url.js#base
- minimal-spa/4-history-api/base-url.js#export
- minimal-spa/4-history-api/path.js#updatePath
- minimal-spa/4-history-api/index.js#show
3.5 Compatibilité
Initialisation du routeur
- minimal-spa/5-routes/router.js#support
- minimal-spa/5-routes/router.js#updatePath
- minimal-spa/5-routes/router.js#replacePath
Compléments
- minimal-spa/5-routes/frameworks/vue.js
- (embarqué) js
3.6 Réécriture des URL côté serveur
Exemples de configuration
- minimal-spa/4-history-api/server/local-web-server.session.sh
- minimal-spa/4-history-api/server/web-dev-server.session.sh
- minimal-spa/4-history-api/server/example.apache.conf#directory
- minimal-spa/4-history-api/server/example.nginx.conf
- minimal-spa/4-history-api/server/firebase.json
4. Définir des routes
4.1 Uniformiser le rendu dynamique
Refactoring du rendering
- minimal-spa/5-routes/2-sync/index.html#main
- minimal-spa/5-routes/rendering.js#home
- minimal-spa/5-routes/rendering.js#render
- minimal-spa/1-fundamentals/fetch.js#getPostData
- minimal-spa/5-routes/rendering.js#post
4.2 Définir une collection de routes
Routage asynchrone (mauvaise pratique)
- minimal-spa/5-routes/1-async/router.js#routes
Routage synchrone
- minimal-spa/5-routes/2-sync/router.js#routes
- minimal-spa/5-routes/2-sync/router.js#navigate
- minimal-spa/5-routes/2-sync/index.html#nav
4.3 Définir une route par défaut
Compléments
- (embarqué) javascript
- minimal-spa/5-routes/router.js#getPath
- minimal-spa/5-routes/2-sync/index.js#navigate
Redirections
- minimal-spa/5-routes/3-redirect/router.js#routes
- (embarqué) javascript
- minimal-spa/5-routes/rendering.js#error
- minimal-spa/5-routes/3-redirect/router.js#errorRoute
- minimal-spa/5-routes/3-redirect/router.js#navigate
4.4 Approche des principaux frameworks
Exemples
- minimal-spa/5-routes/frameworks/angular-routes.ts
- minimal-spa/5-routes/frameworks/angular-resolver.ts
- minimal-spa/5-routes/frameworks/vue.js
- minimal-spa/5-routes/frameworks/page.js
- minimal-spa/5-routes/frameworks/react.jsx
5. Transmettre des données
5.1 Paramètres de route
Paramètres de route
- minimal-spa/5-routes/3-redirect/router.js#postRoutes
- minimal-spa/6-data/1-route-params/routes.js#postPath
- minimal-spa/6-data/1-route-params/router.js#simpleMatch
- minimal-spa/6-data/1-route-params/routes.js#post
- minimal-spa/6-data/1-route-params/router.js#match
- minimal-spa/6-data/1-route-params/router.js#callMatch
- minimal-spa/6-data/1-route-params/router.js#data
- minimal-spa/6-data/1-route-params/routes.js#default
- minimal-spa/6-data/1-route-params/router.js#redirect
- minimal-spa/6-data/1-route-params/router.js#navigate
(bonus) Paramètres de route avec path-to-regexp
5.2 Paramètres d'URL
Paramètres d'URL
- minimal-spa/6-data/rendering.js#postDataError
- minimal-spa/6-data/2-query-params/fetch.js#postData
- minimal-spa/6-data/2-query-params/routes.js#postError
- minimal-spa/6-data/2-query-params/router.js#data
- minimal-spa/6-data/2-query-params/router.js#initialGetParams
- minimal-spa/6-data/2-query-params/router.js#mergeParams
- minimal-spa/6-data/2-query-params/router.js#concatPath
- minimal-spa/6-data/rendering.js#postError
5.3 Objets état associés à l’historique
Objet état
- minimal-spa/6-data/3-history-state/fetch.js#checkInt
- minimal-spa/6-data/3-history-state/routes.js#error
- (embarqué) js
- minimal-spa/6-data/3-history-state/router.js#data
- minimal-spa/6-data/rendering.js#error
6. Navigation et changement de route
via onclick
- minimal-spa/7-navigation/1-callback/index.html#link
- minimal-spa/7-navigation/1-callback/index.js#callback
gestion globale
5.6.1 - Gestion globale
- (embarqué) javascript
- minimal-spa/7-navigation/2-global/navigation.js#exclusions
- minimal-spa/7-navigation/2-global/navigation.js#click
5.6.2 - Évènement `popstate`
- minimal-spa/7-navigation/2-global/navigation.js#onpopstate
- minimal-spa/7-navigation/2-global/router.js#navigate
Chapitre 6 : Afficher des données
dynamiquement
De nombreux exemples utilisés dans ce chapitre sont issus des projets "Benchmark" et modern-helpers, et ne sont donc pas disponibles dans cette archive. Vous pourrez cependant les retrouver en suivant le lien indiqué.
1. Optimiser le chargement initial
1.3 Audit des performances du chargement initial
Performance API
- rendering/performance-api/observer.js#observer
- rendering/performance-api/observer.js#callback
2. Comparer différentes approches
Freeze
- (embarqué) js
- rendering/limitations/dom-api/heavy-rendering/create-content.js#render
2.2 Implémentation des tests de performance
Benchmark : vanillajs-create-el
- (benchmark) frameworks/keyed/vanillajs-create-el-for-doc/index.html#table
- (embarqué) html
- (benchmark) frameworks/keyed/vanillajs-create-el-for-doc/index.html#jumbotron
- (benchmark) frameworks/keyed/vanillajs-create-el-for-doc/src/Main.js#main-constructor
3. Bien utiliser la DOM API
3.1 Créer un ensemble d'éléments
Benchmark : vanillajs-create-el
3.2 Mettre à jour le contenu d’un élément
Benchmark : vanillajs-no-mem-query
- (benchmark) frameworks/keyed/vanillajs-no-mem-query/src/Main.js#update
- (benchmark) frameworks/keyed/vanillajs-no-mem/src/Main.js#update
4. Littéraux de gabarits & innerHTML
mauvaise pratique
- rendering/create-element/innerHTML/very-bad/create-elements.js
4.1 Gérer les évènements
conversion des handlers en chaînes de caractères (mauvaise pratique)
- rendering/create-element/innerHTML/bad-handlers/create-elements.js#render
- rendering/create-element/innerHTML/bad-handlers/rendered.html
- rendering/create-element/innerHTML/bad-handlers/create-elements.js#count
handlers locaux
- rendering/create-element/innerHTML/handlers/local/create-elements.js#component
- rendering/create-element/innerHTML/handlers/local/create-elements.js#create
handler global
- rendering/create-element/innerHTML/handlers/global/create-elements.js#constructor
4.2 Mettre à jour le contenu de l’élément
bonnes pratiques
- rendering/create-element/innerHTML/better/create-elements.js#render
- rendering/create-element/innerHTML/better/create-elements.js#update
- rendering/create-element/innerHTML/better/create-elements.js#actions
4.3 Performances
Benchmark : vanillajs-innerhtml
- (benchmark) frameworks/keyed/vanillajs-innerhtml/src/Main.js#create-row
- (embarqué) js
- (benchmark) frameworks/keyed/vanillajs-innerhtml-no-mem/src/Main.js#update
5. HyperScript
5.4 Créer une fonction HyperScript
Exemple de helper HyperScript
- (embarqué) bash
- (embarqué) js
- (helpers) el/index.js
- rendering/create-element/hyperscript/index.js#render
6. Minimiser les accès au DOM
6.2 Fragments
Exemple d'utilisation d'un fragment
- rendering/create-element/dom-api/fragment/create-elements.js#createDocumentFragment
- rendering/create-element/dom-api/fragment/create-elements.js#counter
- rendering/create-element/dom-api/fragment/create-elements.js#createActions
- rendering/create-element/dom-api/fragment/create-elements.js#attach
6.3 Mise en cache des éléments
Exemple simple
- rendering/caching/elements/dom-api/create-elements.js#render
- rendering/caching/elements/dom-api/create-elements.js#update
Benchmark : vanillajs-no-mem
- (benchmark) frameworks/keyed/vanillajs-no-mem/src/Main.js#update
Benchmark : vanillajs-create-el-query
- (benchmark) frameworks/keyed/vanillajs-create-el-query/src/Main.js#initRows
- (benchmark) frameworks/keyed/vanillajs-create-el-query/src/Main.js#appendRows
- (benchmark) frameworks/keyed/vanillajs-create-el-query/src/Main.js#update
Benchmark : vanillajs-create-el
- (benchmark) frameworks/keyed/vanillajs-create-el/src/Main.js#update
6.5 Comparaison avec les littéraux de gabarits
innerHTML avec mise en cache de l'élément enfant
- rendering/caching/elements/innerHTML/create-elements.js#render
- rendering/caching/elements/innerHTML/create-elements.js#update
Benchmark : vanillajs-innerhtml-cpnt
- (benchmark) frameworks/keyed/vanillajs-innerhtml-cpnt/src/Main.js#create-row
- (benchmark) frameworks/keyed/vanillajs-innerhtml-cpnt/src/Main.js#update
6.6 Mettre en cache un élément avec HyperScript
HyperScript avec mise en cache de l'élément enfant
- rendering/caching/elements/hyperscript/index.js#render
- rendering/caching/elements/hyperscript/index.js#update
Benchmark : modern-helpers
- (benchmark) frameworks/keyed/modern-helpers/src/index.js#create-row
- (benchmark) frameworks/keyed/modern-helpers/src/index.js#update
6.6 Mise en cache de l'état
mise en cache de l'état (DOM API)
- rendering/caching/state/dom-api/latest-count/create-elements.js#input
- rendering/caching/state/dom-api/latest-count/create-elements.js#set
- rendering/caching/state/dom-api/latest-count/create-elements.js#update
6.7 Mettre en cache l’état
Memoïsation (DOM API)
- rendering/memoize/utils/latest.js
- rendering/memoize/utils/latest-with-context.js#memoization
7. Optimiser pour la répétition
7.1 Optimiser la mise en cache des éléments avec cloneNode()
Mise en cache sans copie
- rendering/caching/children/without-copy/create-elements.js#memoization
- rendering/caching/children/without-copy/create-elements.js#render
- rendering/caching/children/without-copy/create-elements.js#get
- rendering/caching/children/on-call/create-elements.js#get
Benchmark : vanillajs-prog
- (benchmark) frameworks/keyed/vanillajs-prog/src/Main.js#row-template
- (benchmark) frameworks/keyed/vanillajs-prog/src/Main.js#createRow
7.2 Utiliser innerHTML pour améliorer la lisibilité
Benchmark : vanillajs-dx-opti
- (benchmark) frameworks/keyed/vanillajs-dx-opti/src/Main.js#row-template
7.3 Construire sa propre solution
Benchmark : modern-helpers
- (helpers) el/index.js
- (benchmark) frameworks/keyed/modern-helpers/src/index.js#create-row
- (helpers) template/index.js#part
- (embarqué) js
Benchmark : modern-helpers-template
- (helpers) template/index.js#constructor
- (benchmark) frameworks/keyed/modern-helpers-template/src/index.js#template
- (helpers) template/index.js#parse
- (helpers) template/index.js#createElement
- (helpers) template/index.js#renderInit
- (helpers) template/index.js#loopMeta
- (helpers) template/index.js#proxy
- (benchmark) frameworks/keyed/modern-helpers-template/src/index.js#update
- (benchmark) frameworks/keyed/modern-helpers-template/src/index.js#select
Chapitre 7 : Utiliser les bons outils
2. Vanilla Web et les microbibliothèques
2.5 Aides à la manipulation du DOM
Benchmark : jquery
- (benchmark) frameworks/keyed/jquery/src/index.js#create-row
2.7 RE:DOM
RE:DOM (minimal-spa)
- (embarqué) js
- minimal-spa/redom/views/home.js#Home
- minimal-spa/redom/views/post.js#Post
- minimal-spa/redom/views/not-found.js#NotFound
- minimal-spa/redom/router.js#router
- minimal-spa/redom/router.js#navigate
- (embarqué) js
- minimal-spa/redom/components/menu.js#Menu
- minimal-spa/redom/components/app.js#App
- minimal-spa/redom/main.js#mount
3. Bibliothèques de rendering
3.1 Principe des étiquettes de gabarits
Introduction aux tagged templates
- (embarqué) js
- (embarqué) js
- (embarqué) js
- rendering/tagged-template/index.js#tag
- rendering/tagged-template/index.js#create
3.5 Exemple d'application
Benchmark : lit-html
- (embarqué) typescript
- (benchmark) frameworks/keyed/lit-html-for-doc/src/index.js#row-template
- (embarqué) js
- (embarqué) js
- (embarqué) js
- (embarqué) js
- (benchmark) frameworks/keyed/lit-html-for-doc/src/index.js#render
- (benchmark) frameworks/keyed/lit-html-for-doc/src/index.js#update
4. Modularité et programmation orientée composants
4.1 Principes de lit-element
Hello World (lit-element)
- (embarqué) js
- libs/lit-element/helloworld.js#component
- libs/lit-element/async-helloworld.js#render
- libs/lit-element/async-helloworld.js#properties
- libs/lit-element/async-helloworld.js#constructor
- libs/lit-element/async-helloworld.js#styles
5. Programmation réactive
RxJS
7.5.3 - Observable et opérateurs
- libs/reactive/rxjs/complete/index.js#observable
- (embarqué) js
- (embarqué) text
- libs/reactive/rxjs/complete/index.js#map
- libs/reactive/rxjs/complete/index.js#filter
- libs/reactive/rxjs/complete/index.js#distinctUntilChanged
- libs/reactive/rxjs/complete/index.js#debounceTime
- libs/reactive/rxjs/complete/index.js#tap
7.5.4 - Combiner des observables
- (embarqué) js
- libs/reactive/rxjs/complete/index.js#fromFetch
- libs/reactive/rxjs/complete/index.js#switchMap
5.5 hot et cold observables
Cold Observable
- libs/reactive/rxjs/complete/cold/index.js#observable
- libs/reactive/rxjs/complete/index.js#subscription
- libs/reactive/rxjs/complete/index.js#console
5.6 Alternatives à RxJS
Bacon.js
- libs/reactive/baconjs/index.js#bacon
6. Gestion d'état
6.1 Créer un conteneur d’état avec Redux
Redux : compteur simple
- libs/reactive/redux/simple-counter/store.js
- libs/reactive/redux/simple-counter/redux-counter.js#component
6.2 Permettre à des composants de partager un état
Redux : composant wrapper
- libs/reactive/redux/wrapped-counter/demo-counter.js#component
- libs/reactive/redux/wrapped-counter/demo-nav.js#component
- (embarqué) js
6.3 Rendre les composants indépendants de l'état global
Redux : composant wrapper
- (embarqué) js
- libs/reactive/redux/wrapped-counter/redux-wrapper.js#bindParam
- libs/reactive/redux/wrapped-counter/redux-wrapper.js#subscribe
- (embarqué) js
- libs/reactive/redux/wrapped-counter/index.html#props
- libs/reactive/redux/wrapped-counter/redux-wrapper.js#actionsParam
- libs/reactive/redux/wrapped-counter/redux-wrapper.js#dispatch
- libs/reactive/redux/wrapped-counter/index.html#actions
Bonus: Redux : exemple plus réaliste
7. Routeurs
7.1 Page.js
minimal-spa avec Page.js
- minimal-spa/8-pagejs/index.js#routes
- minimal-spa/8-pagejs/index.js#config
- minimal-spa/8-pagejs/index.html#link
7.2 Universal-router
minimal-spa avec Universal-router
- minimal-spa/9-universal-router/index.js#routes
- minimal-spa/9-universal-router/index.js#resolve
- minimal-spa/9-universal-router/index.js#navigate