SlideShare une entreprise Scribd logo
1  sur  67
@cherif_b
Plan

Introduction
● Caractéristiques
● Pourquoi CanJS?
● Demo
● Q&R
●
CanJS is a JavaScript library that makes
developing complex applications simple and fast.
Easy-to-learn, small, and unassuming of your
application structure, but with modern features
like custom tags and 2-way binding. Creating
apps is easy and maintainable.
Créé par
Un MVC Framework
Un MVC Framework

Model
Un MVC Framework

Model

Vue
Un MVC Framework
Component/Control

Model

Vue
Un MVC Framework
Component/Control

ts
en
Ev

Model

Vue
Un MVC Framework

à
Mi
se

Model

ts
en
Ev

jou
r

Component/Control

Vue
Un MVC Framework

Mi
se

à

ts
en
Ev

jou
r

Component/Control

Model

MAJ avec 2 way binding

Vue
Un MVC Framework

Mi
se

à

ts
en
Ev

jou
r

Component/Control

Model

MAJ avec 2 way binding

Vue
Caractéristiques
can.Map
(Objets Observables)
can.Contsruct
(Constructeurs)

can.Control
(Controlleurs)

can.Model
(Models)
can.route
(Routage)

can.Component
(Composant)
can.compute
(Valeurs Observables)

can.view.ejs
(Embeded JS)

can.view
(Vue)
can.view.mustache
(Mustache/Handlebars)
can.Construct.extend(s,p)
var Person = can.Construct.extend({
init: function (name) {
this.name = name;
}
});
var cherif = new Person("Cherif");
cherif.name
new can.Map(data)
var person = new can.Map({name:'Cherif'});

person.attr('name') //-> 'Cherif'
person.bind('name',function(ev,newVal,oldVal){

newVal //-> 'Khaled'
oldVal //-> 'Cherif'
});
person.attr('name','Khaled');
new can.List(data)
var hobbies = new can.List(['JS']);
hobbies.attr(0) //-> 'JS'
hobbies.bind('add',function(ev,items,index){
items //-> ['bball','football']
index //-> 1
});
hobbies.push('bball','football');
can.compute(data)
var age = can.compute(30);
age(); //-> 30
age.bind('change',function(ev,newVal,oldVal){
newVal //-> 31
oldVal //-> 30
});
age(31);
can.compute(getter)
var info = can.compute(function(){
return person.attr("name")+" a "+age()+
" ans et aime: "+hobbies.join(', ')
});
info() //-> "Cherif a 31 ans et aime JS, bball, football"
info.bind('change',function(ev,newVal,oldVal){
newVal //-> "Cherif a 31 ans et aime JS, bball"
});
hobbies.pop();
can.Model.extend(s,p)
var Task = can.Model.extend({
findAll: "GET
findOne: "GET

/tasks",
/tasks/{id}",

create: "POST /tasks",
update: "PUT

/tasks/{id}",

destroy: "DELETE /tasks/{id}"
},{})
Task.findAll({due:"today"},function(tasks){})
Task.findOne({id: 51},function(task){});
can.Model.extend(s,p)
var task = new Task({name:"Apprendre CanJS."});
task.save(function(){
task.attr("name","Apprendre JS et CanJS.")
.save(function(){
task.destroy()
})
})
can.Model.List(s,p)
var tasks= new Task.List();
can.each(tasks,function(task){
});
Task.List = can.Model.List.extend({
Map: Task
},{});
can.route(route,defaults)
can.route("tasks/:id",{ type: "tasks"});
can.route.bind("change", function(){
if(can.route.attr('type') == "tasks"){
var id = can.route.attr('id’);
if( id ){
Task.findOne({id: id});
}e
}
});
can.Control.extend( p )
var Tabs = can.Control.extend({
init: function( el,options ) {
// Afficher le premier onglet
},
'li click': function( el, ev ) {
// Masquer les autes onglet
// Afficher l'onglet selectioné
}
});
new Tabs('#tabs');
Mustache / Handlebars
{{#if devs.length}}
{{#each devs}}
<li>{{name}}</li>
{{/each}}
{{else}}
<li>pas de développeurs</li>
{{/if}}
can.view('devs.mustache',{
devs: new can.List([{name:'Khaled'}])
})
EJS
<% if( devs.attr('length') ) { %>
<% devs.each(function(dev){ %>
<li><%= dev.attr('name') %></li>
<% }) %>
<% } else { %>
<li>pas de développeurs</li>
<% } %>
can.view('devs.ejs',{
devs: new can.List([{name:'Khaled'}])
})
can.Component.extend(p)
can.Component.extend({
tag:"panel",
template: "{{#if active}}<content>…",
scope: {
active: false
},
helpers: {}
events: {
inserted: function(){...}
}
})
can.Component.extend(p)
<tabs>
{{#each foodTypes}}
<panel title='title'>
{{content}}
</panel>
{{/each}}
</tabs>
var foodTypes= new can.List([
{title:"Fruits",content:"oranges"}, …])
2 way binding
var Voyage= can.Map.extend({
voyageTemp:function(){
return this.attr('dist')/110 //km/h
}
});
var alger=new Voyage({
dist:563.67
});
var template=can.view.mustache('<p><lable>distance:</label>
<input can-value="dist"/></p>
<p>Temp:{{voyageTemp}}</p>');
$('#vo').html(template(alger));
Plugins
Validations
Getter / Setter
Backup / Restore
Super
Queue
Delegate
PushState
Fixtures
LazyMap
POURQUOI?
Découplage
n ( n – 1 ) / 2
{
ticker: "SSE",
startTime: 1350709200000, // Oct 20, 2012
endTime: 1350795600000 // Oct 21, 2012
}
Flexibilité
Support des librairies
Faites le à votre maniére
<slider min="0" max="100"></slider>
new Slider("#progress",{
min: 0,
max: 100
});
$("#progress").slider({
min: 0,
max: 100
});
Faites le à votre maniére
Task = can.Model.extend({
findAll: "/GET /tasks"
},{})
Task = can.Model.extend({
findAll: {
crossDomain: true,
dataType: "jsonp",
jsonpCallback: "callback"
}
},{})
Faites le à votre maniére
Task = can.Model.extend({
findAll: "/GET /tasks"
},{})
Task = can.Model.extend({
findAll: function(params){
var deferred = $.Deferred();
connect(function(data){
deferred.resolve(Task.models(data))
});
return deferred;
}
},{})
Comparaison
Caratéristiques

AngularJS

Backbone

CanJS

EmberJS

Observables

O

N

O

O

Routing

O

O

O

O

View Binding

O

N

O

O

Two way Bindings

O

N

O

O

Partial views

O

N

O

O

Filtred List views

O

N

O

O

Flexibilty

N

O

O

N
Courbe d'apprentissage

Grande!!
Courbe d'apprentissage

Petite
Courbe d'apprentissage

Grande!!
Courbe d'apprentissage
l

Petite!!
Question / Réponse
●

http://www.bitovi.com/

●

http://www.bitovi.com/blog/

●

http://canjs.com/

●

https://github.com/bitovi/

●

https://github.com/retro/generator-canjs/

Contenu connexe

Tendances

hachioji.pm #40 : asynchronous in JS
hachioji.pm #40 : asynchronous in JShachioji.pm #40 : asynchronous in JS
hachioji.pm #40 : asynchronous in JS
Kotaro Kawashima
 
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - MojitoDundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojito
smartads
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
Yehuda Katz
 

Tendances (20)

[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Human Talks Riot.js
Human Talks Riot.jsHuman Talks Riot.js
Human Talks Riot.js
 
NodeJS in Windows Azure
NodeJS in Windows AzureNodeJS in Windows Azure
NodeJS in Windows Azure
 
Expressを使ってみた
Expressを使ってみたExpressを使ってみた
Expressを使ってみた
 
hachioji.pm #40 : asynchronous in JS
hachioji.pm #40 : asynchronous in JShachioji.pm #40 : asynchronous in JS
hachioji.pm #40 : asynchronous in JS
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Requirejs
RequirejsRequirejs
Requirejs
 
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - MojitoDundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojito
 
OUTDATED (Encore)
OUTDATED (Encore)OUTDATED (Encore)
OUTDATED (Encore)
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
лукьянченко л.а. пос 10а
лукьянченко л.а. пос 10алукьянченко л.а. пос 10а
лукьянченко л.а. пос 10а
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
 
A re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiA re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbai
 
Dive into AngularJS Routing
Dive into AngularJS RoutingDive into AngularJS Routing
Dive into AngularJS Routing
 
jQuery 實戰經驗講座
jQuery 實戰經驗講座jQuery 實戰經驗講座
jQuery 實戰經驗講座
 
Mojolicious on Steroids
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on Steroids
 
Damage Control
Damage ControlDamage Control
Damage Control
 
Criando um componente de busca com AngularJS
Criando um componente de busca com AngularJSCriando um componente de busca com AngularJS
Criando um componente de busca com AngularJS
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Ember: Guts & Goals
Ember: Guts & GoalsEmber: Guts & Goals
Ember: Guts & Goals
 

En vedette

Pgd0015 group dynamic topic 2
Pgd0015 group dynamic topic 2Pgd0015 group dynamic topic 2
Pgd0015 group dynamic topic 2
Melvin Yap
 
Deep sec talk - Addressing the skills gap
Deep sec talk - Addressing the skills gapDeep sec talk - Addressing the skills gap
Deep sec talk - Addressing the skills gap
Colin McLean
 
M&m project Bryanna and Josh
M&m project   Bryanna and JoshM&m project   Bryanna and Josh
M&m project Bryanna and Josh
newham5-6
 
Esaera zaharrak
Esaera zaharrakEsaera zaharrak
Esaera zaharrak
losperxas
 

En vedette (20)

Voorleeskwartierklasjecircus
VoorleeskwartierklasjecircusVoorleeskwartierklasjecircus
Voorleeskwartierklasjecircus
 
Instagram + NBC News
Instagram + NBC NewsInstagram + NBC News
Instagram + NBC News
 
Pgd0015 group dynamic topic 2
Pgd0015 group dynamic topic 2Pgd0015 group dynamic topic 2
Pgd0015 group dynamic topic 2
 
AIESEC 101 - Just Like Me
AIESEC 101 - Just Like MeAIESEC 101 - Just Like Me
AIESEC 101 - Just Like Me
 
另辟蹊径学英语,面向对象英语语法(Object oriented english grammar net version)
另辟蹊径学英语,面向对象英语语法(Object oriented english grammar net version)另辟蹊径学英语,面向对象英语语法(Object oriented english grammar net version)
另辟蹊径学英语,面向对象英语语法(Object oriented english grammar net version)
 
Ortografia emprego x
Ortografia emprego xOrtografia emprego x
Ortografia emprego x
 
Catalogo Empresa Simulada Ociplana
Catalogo Empresa Simulada OciplanaCatalogo Empresa Simulada Ociplana
Catalogo Empresa Simulada Ociplana
 
Regalia - Luxury Oceanfront
Regalia - Luxury OceanfrontRegalia - Luxury Oceanfront
Regalia - Luxury Oceanfront
 
939 New Patient Machine
939 New Patient Machine939 New Patient Machine
939 New Patient Machine
 
Winnaar #watishijmooi-prijs
Winnaar #watishijmooi-prijsWinnaar #watishijmooi-prijs
Winnaar #watishijmooi-prijs
 
The Team Workshop Method
The Team Workshop MethodThe Team Workshop Method
The Team Workshop Method
 
Promotional Bag Ideas by Sinoway
Promotional Bag Ideas by SinowayPromotional Bag Ideas by Sinoway
Promotional Bag Ideas by Sinoway
 
Deep sec talk - Addressing the skills gap
Deep sec talk - Addressing the skills gapDeep sec talk - Addressing the skills gap
Deep sec talk - Addressing the skills gap
 
Stadens mest kreativa kvarter
Stadens mest kreativa kvarterStadens mest kreativa kvarter
Stadens mest kreativa kvarter
 
M&m project Bryanna and Josh
M&m project   Bryanna and JoshM&m project   Bryanna and Josh
M&m project Bryanna and Josh
 
Zone-S
Zone-SZone-S
Zone-S
 
TRUSTLESS Inc Long Term View
TRUSTLESS Inc Long Term ViewTRUSTLESS Inc Long Term View
TRUSTLESS Inc Long Term View
 
Esaera zaharrak
Esaera zaharrakEsaera zaharrak
Esaera zaharrak
 
WSA 2013
WSA 2013WSA 2013
WSA 2013
 
Prayer for Truth
Prayer for TruthPrayer for Truth
Prayer for Truth
 

Similaire à Canjs

Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
Aaronius
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
Spine js & creating non blocking user interfaces
Spine js & creating non blocking user interfacesSpine js & creating non blocking user interfaces
Spine js & creating non blocking user interfaces
Hjörtur Hilmarsson
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 

Similaire à Canjs (20)

Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
Emberjs as a rails_developer
Emberjs as a rails_developer Emberjs as a rails_developer
Emberjs as a rails_developer
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
AngularJS and SPA
AngularJS and SPAAngularJS and SPA
AngularJS and SPA
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
 
Spine js & creating non blocking user interfaces
Spine js & creating non blocking user interfacesSpine js & creating non blocking user interfaces
Spine js & creating non blocking user interfaces
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Canjs