SlideShare ist ein Scribd-Unternehmen logo
1 von 28
http://canjs.us
@canjsus
Why?
• Prevents Leaks
• Ease of Use
• Fast
What’s Inside
• can.Construct
• can.Observe
• can.Model
• can.Control
• can.view
• can.EJS
• can.route
can.Construct(static, proto)
var Person = can.Construct({
    init : function (name) {
       this.name = name;
    }
});

var curtis = new Person("Curtis");
curtis.name
new can.Observe(data)
var person =
  new can.Observe({ name: 'josh'});

person.bind('name‟, function(ev,newVal,oldVal){
  newVal //-> 'Josh Dean'
  oldVal //-> 'josh'
});

person.attr('name') //-> 'josh'
person.name //-> 'josh'
person.attr('name','Josh Dean‟);
can.Model(ajax,proto)
var Todo = can.Model({
  findAll : '/todo',
  findOne : '/todo/{id}',
  destroy : 'POST /todo/destroy/{id}',
  update : 'POST /todo/{id}',
  create : '/todo'
},{});

Todo.findOne({id: 5}, function( todo ) {
  todo.attr('name')
});
can.Control(proto)
var Tabs = can.Control({
  init: function( el ) {
     // show first tab
  },
  'li click': function( el, ev ) {
     // hide other tabs
     // show selected tab
  }
});

new Tabs('#tabs');
can.route(route, defaults)
var Routing = can.Control({
 ':type/:id route': function( data ) {

  }
})

new Routing( document.body );
can.route.attr( { type : 'todos', id: 5 } )
can.view( idOrURL, data ) -> fragment

<script type='text/ejs' id='messageEJS'>
 <h1><%= message %></h1>
</script>

can.view('messageEJS', {
  message : 'Hello World'
}) //-> frag <h1>Hello World</h1>
EmbeddedJS Templates

Favorite tag is <%= ‟<blink>Blink</blink>‟ %>

-> My favorite tag is <blink>Blink</blink>




Favorite tag is <%== ‟<blink>Blink</blink>‟ %>

-> Favorite tag is Blink
EmbeddedJS Templates
<% if( devs ) { %>
 <% for( var i = 0; i < devs.length; i++ ) { %>
  <li><%= arr[i] %></li>
 <% } %>
<% } else { %>
 <li>No Developers</li>
<% } %>

can.view('devs.ejs',{devs: ['Andy','Fred']})
//-> frag <li>Andy</li><li>Fred</li>
EJS Live Binding
<% if( devs.attr('length') ) { %>
 <% list(devs, function(dev){ %>
  <li><%= dev.attr(„name‟) %></li>
 <% }) %>
<% } else { %>
 <li>No Developers</li>
<% } %>

var devs = new can.Observe.List([
  {name : 'Andy'}, {name : 'Fred'}
])

can.view('devs.ejs',{devs : devs})
//-> frag <li>Andy</li><li>Fred</li>
Why?
• Prevents Leaks
• Speed
• Flexibility + Libraries
• Ease of Use
• Features vs Size
A tooltip.



                                  Undo




$('#undo').bind('mouseenter',function(){
  $('<div>Undo</div>').tooltipFor(this)
})
What’s Wrong?
$.fn.tooltipFor = function(anchor){
 var $el = this
    .appendTo(document.body)
    .offset( $(anchor).offset() )

    $(anchor).bind('mouseleave',function(ev){
       $el.remove()
    })
}
Leaks
Templated Events “{option} eventName”
Templated Events
var Tooltip = can.Control({
  init: function( el, options ) {
    el.appendTo(document.body)
      .offset( $(options.anchor).offset() )
  },
  '{anchor} mouseleave': function( el, ev ) {
    this.element.remove();
  }
});

new Tooltip($('<div>Undo</div>'),{
  anchor : this
});
Non-leaking Global Store

          Critical           Due Today


     File Taxes            Brush Teeth

     Write talk on CanJS   Write talk on CanJS

     Emissions Test        Check into flight
Non-leaking Global Store

             Awesome Developers
Easy To Use
Plugins
• Validations
• Getter / Setter
• Serialize / Deserialize
• Backup / Restore
• Super
• Proxy


$(“#todos”).html( „todos.ejs‟, Todo.findAll() )
can.Control and Backbone.View




                     http://jsperf.com/tabs-timing-test
Live Binding




               http://jsfiddle.net/JMWf4/5/
Live Binding




*can.zepto.js, angular/ember not tested, ask me why   http://jsperf.com/canjs-ejs-live-bind
Features vs Size
 CanJS 8.49kb      - jQuery


 Backbone 8.97kb   -jQuery
                   +Underscore

 Knockout 13kb     none


 Batman 15kb       -pollyfills for ES5


                   none
 Angular 24kb

                   -jQuery
 Ember 39kb        +metamorph.js
Library Support
Questions?


         safer
        faster
       easier
       smaller
     library-er

  http://canjs.us
    @canjsus

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (20)

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
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
 
OUTDATED (Encore)
OUTDATED (Encore)OUTDATED (Encore)
OUTDATED (Encore)
 
hachioji.pm #40 : asynchronous in JS
hachioji.pm #40 : asynchronous in JShachioji.pm #40 : asynchronous in JS
hachioji.pm #40 : asynchronous in JS
 
Requirejs
RequirejsRequirejs
Requirejs
 
Expressを使ってみた
Expressを使ってみたExpressを使ってみた
Expressを使ってみた
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
Dive into AngularJS Routing
Dive into AngularJS RoutingDive into AngularJS Routing
Dive into AngularJS Routing
 
Angular JS Routing
Angular JS RoutingAngular JS Routing
Angular JS Routing
 
лукьянченко л.а. пос 10а
лукьянченко л.а. пос 10алукьянченко л.а. пос 10а
лукьянченко л.а. пос 10а
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced Routing
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Jquery ui
Jquery uiJquery ui
Jquery ui
 
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
 
Damage Control
Damage ControlDamage Control
Damage Control
 
Ember: Guts & Goals
Ember: Guts & GoalsEmber: Guts & Goals
Ember: Guts & Goals
 
UI-Router
UI-RouterUI-Router
UI-Router
 

Andere mochten auch

Why Docker
Why DockerWhy Docker
Why Docker
dotCloud
 
Gardler bosc2010 community_developmentattheasf
Gardler bosc2010 community_developmentattheasfGardler bosc2010 community_developmentattheasf
Gardler bosc2010 community_developmentattheasf
BOSC 2010
 

Andere mochten auch (16)

Bending the Rules: Community over Code over Policy.
Bending the Rules: Community over Code over Policy.Bending the Rules: Community over Code over Policy.
Bending the Rules: Community over Code over Policy.
 
Open Development in the Enterprise, October 2013 edition
Open Development in the Enterprise, October 2013 editionOpen Development in the Enterprise, October 2013 edition
Open Development in the Enterprise, October 2013 edition
 
Open Source In Education
Open Source In EducationOpen Source In Education
Open Source In Education
 
Dev cloud
Dev cloudDev cloud
Dev cloud
 
Open Source enables Open Innovation
Open Source enables Open InnovationOpen Source enables Open Innovation
Open Source enables Open Innovation
 
Life in Open Source Communities, ApacheCon US 2009
Life in Open Source Communities, ApacheCon US 2009Life in Open Source Communities, ApacheCon US 2009
Life in Open Source Communities, ApacheCon US 2009
 
Keynote apache bd-eu-nov-2016
Keynote apache bd-eu-nov-2016Keynote apache bd-eu-nov-2016
Keynote apache bd-eu-nov-2016
 
Hortonworks apache training
Hortonworks apache trainingHortonworks apache training
Hortonworks apache training
 
Open Source at scale: the Apache Software Foundation
Open Source at scale: the Apache Software FoundationOpen Source at scale: the Apache Software Foundation
Open Source at scale: the Apache Software Foundation
 
Open-Source Collaboration Tools are Good for You - 2009 edition
Open-Source Collaboration Tools are Good for You - 2009 editionOpen-Source Collaboration Tools are Good for You - 2009 edition
Open-Source Collaboration Tools are Good for You - 2009 edition
 
Cloud stack for_beginners
Cloud stack for_beginnersCloud stack for_beginners
Cloud stack for_beginners
 
Why Docker
Why DockerWhy Docker
Why Docker
 
Gardler bosc2010 community_developmentattheasf
Gardler bosc2010 community_developmentattheasfGardler bosc2010 community_developmentattheasf
Gardler bosc2010 community_developmentattheasf
 
Successfully Profiting From Apache Brands
Successfully Profiting From Apache BrandsSuccessfully Profiting From Apache Brands
Successfully Profiting From Apache Brands
 
Improving Your Apache Project's Image And Brand
 Improving Your Apache Project's Image And Brand Improving Your Apache Project's Image And Brand
Improving Your Apache Project's Image And Brand
 
Practical Trademark Law for FOSS Projects
Practical Trademark Law for FOSS ProjectsPractical Trademark Law for FOSS Projects
Practical Trademark Law for FOSS Projects
 

Ähnlich wie Canjs

jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
Paul Irish
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
Kris Wallsmith
 

Ähnlich wie Canjs (20)

Summit2014 topic 0066 - 10 enhancements that require 10 lines of code
Summit2014 topic 0066 - 10 enhancements that require 10 lines of codeSummit2014 topic 0066 - 10 enhancements that require 10 lines of code
Summit2014 topic 0066 - 10 enhancements that require 10 lines of code
 
Assetic (Zendcon)
Assetic (Zendcon)Assetic (Zendcon)
Assetic (Zendcon)
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Assetic (OSCON)
Assetic (OSCON)Assetic (OSCON)
Assetic (OSCON)
 
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
 
Sequelize
SequelizeSequelize
Sequelize
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
前端MVC之BackboneJS
前端MVC之BackboneJS前端MVC之BackboneJS
前端MVC之BackboneJS
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for Performance
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
jQuery Basic API
jQuery Basic APIjQuery Basic API
jQuery Basic API
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
Practical HTML5: Using It Today
Practical HTML5: Using It TodayPractical HTML5: Using It Today
Practical HTML5: Using It Today
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Canjs

  • 2. Why? • Prevents Leaks • Ease of Use • Fast
  • 3. What’s Inside • can.Construct • can.Observe • can.Model • can.Control • can.view • can.EJS • can.route
  • 4. can.Construct(static, proto) var Person = can.Construct({ init : function (name) { this.name = name; } }); var curtis = new Person("Curtis"); curtis.name
  • 5. new can.Observe(data) var person = new can.Observe({ name: 'josh'}); person.bind('name‟, function(ev,newVal,oldVal){ newVal //-> 'Josh Dean' oldVal //-> 'josh' }); person.attr('name') //-> 'josh' person.name //-> 'josh' person.attr('name','Josh Dean‟);
  • 6. can.Model(ajax,proto) var Todo = can.Model({ findAll : '/todo', findOne : '/todo/{id}', destroy : 'POST /todo/destroy/{id}', update : 'POST /todo/{id}', create : '/todo' },{}); Todo.findOne({id: 5}, function( todo ) { todo.attr('name') });
  • 7. can.Control(proto) var Tabs = can.Control({ init: function( el ) { // show first tab }, 'li click': function( el, ev ) { // hide other tabs // show selected tab } }); new Tabs('#tabs');
  • 8. can.route(route, defaults) var Routing = can.Control({ ':type/:id route': function( data ) { } }) new Routing( document.body ); can.route.attr( { type : 'todos', id: 5 } )
  • 9. can.view( idOrURL, data ) -> fragment <script type='text/ejs' id='messageEJS'> <h1><%= message %></h1> </script> can.view('messageEJS', { message : 'Hello World' }) //-> frag <h1>Hello World</h1>
  • 10. EmbeddedJS Templates Favorite tag is <%= ‟<blink>Blink</blink>‟ %> -> My favorite tag is <blink>Blink</blink> Favorite tag is <%== ‟<blink>Blink</blink>‟ %> -> Favorite tag is Blink
  • 11. EmbeddedJS Templates <% if( devs ) { %> <% for( var i = 0; i < devs.length; i++ ) { %> <li><%= arr[i] %></li> <% } %> <% } else { %> <li>No Developers</li> <% } %> can.view('devs.ejs',{devs: ['Andy','Fred']}) //-> frag <li>Andy</li><li>Fred</li>
  • 12. EJS Live Binding <% if( devs.attr('length') ) { %> <% list(devs, function(dev){ %> <li><%= dev.attr(„name‟) %></li> <% }) %> <% } else { %> <li>No Developers</li> <% } %> var devs = new can.Observe.List([ {name : 'Andy'}, {name : 'Fred'} ]) can.view('devs.ejs',{devs : devs}) //-> frag <li>Andy</li><li>Fred</li>
  • 13. Why? • Prevents Leaks • Speed • Flexibility + Libraries • Ease of Use • Features vs Size
  • 14. A tooltip. Undo $('#undo').bind('mouseenter',function(){ $('<div>Undo</div>').tooltipFor(this) })
  • 15. What’s Wrong? $.fn.tooltipFor = function(anchor){ var $el = this .appendTo(document.body) .offset( $(anchor).offset() ) $(anchor).bind('mouseleave',function(ev){ $el.remove() }) }
  • 16. Leaks
  • 18. Templated Events var Tooltip = can.Control({ init: function( el, options ) { el.appendTo(document.body) .offset( $(options.anchor).offset() ) }, '{anchor} mouseleave': function( el, ev ) { this.element.remove(); } }); new Tooltip($('<div>Undo</div>'),{ anchor : this });
  • 19. Non-leaking Global Store Critical Due Today File Taxes Brush Teeth Write talk on CanJS Write talk on CanJS Emissions Test Check into flight
  • 20. Non-leaking Global Store Awesome Developers
  • 22. Plugins • Validations • Getter / Setter • Serialize / Deserialize • Backup / Restore • Super • Proxy $(“#todos”).html( „todos.ejs‟, Todo.findAll() )
  • 23. can.Control and Backbone.View http://jsperf.com/tabs-timing-test
  • 24. Live Binding http://jsfiddle.net/JMWf4/5/
  • 25. Live Binding *can.zepto.js, angular/ember not tested, ask me why http://jsperf.com/canjs-ejs-live-bind
  • 26. Features vs Size CanJS 8.49kb - jQuery Backbone 8.97kb -jQuery +Underscore Knockout 13kb none Batman 15kb -pollyfills for ES5 none Angular 24kb -jQuery Ember 39kb +metamorph.js
  • 28. Questions? safer faster easier smaller library-er http://canjs.us @canjsus

Hinweis der Redaktion

  1. Hello, I&apos;m Justin Meyer from BitoviI&apos;m very proud that this is the second time Bitovi (formerly Jupiter) has sponsered JSConfThis year it comes at an important time for us. Not only are we announcing the rebranding at this conference (we are Bitovi now), we are releasing thenext version of JavaScriptMVC&apos;s MVC parts called CanJS.In this talk, I&apos;ll introduce what&apos;s inside CanJS and talk about why, despite a lot of great existing MVC libraries, we think CanJS is the best one the market.
  2. It will fix the memory leaks that you probably don’t even know you have.Fastest control initialization and live template binding. Your app will start fast and run fast.And it’s super easy to pick up, we documented the hello out of it.
  3. positivity
  4. A basic constructor function helper. Useful for providing inheritance. All of JMVC’s constructors inherit from it.
  5. A basic constructor function helper. Useful for providing inheritance
  6. A basic constructor function helper. Useful for providing inheritance hooks up observes to your back end with declarative service bindings
  7. A basic constructor function helper. Useful for providing inheritance
  8. A basic constructor function helper. Useful for providing inheritance - A special observe that is cross bound to the route - pretty urls
  9. ----- Meeting Notes (4/3/12 00:38) -----embedded js
  10. show changing the obseveralph giving the talk
  11. Leaking Event HandlersCleaning Data Stores
  12. Impossible to create memory leaksPeople don&apos;t know what they are doingCan see it in something as simple as a tool tip where you mouseover the elementand it shows the tooltip widget.You might use this tooltip widget like the following: listen on an anchor element, create the content for the tooltip call tooltipFor with the anchor
  13. can.Control fixes this with templated event handlersYou can bind events that will always be unbound auto-magically
  14. ----- Meeting Notes (4/3/12 00:38) -----cleaned up
  15. The next way CanJS helps with memory is through it’s non-leaking global store. Say we have 2 Todo lists, Critical Todos and today’s todos. These lists might get back data for the same instance of a todo. The problem happens when a user changes properties on a todo that exists in both lists. Both lists need to be listening to property changes on the same todo instance.Model needs to see that the data it retrieves belongs to the same instance and return the previously created instance instead of creating a new one.Most MVC libraries either ignore it or solve it with a model store that has all instances, when data is retrieved for an instance, it checks if the instance is already created and uses that instance instead of creating a new one.The problem with this is for long-lived applications, you are constantly collecting unused instances, which fills memory. The developer has to tell the store when to flush instances.CanJS solves this by keeping things in the store only when it knows you are interested in them. How do you express interest? Well by binding to the instance. So, Model keeps instances in the store only while they have event handlers.This, combined with templated event handling, means that simply by replacing the todo list ELEMENTs with a list of “Awesome Developers”&lt;li class=“&lt;%= todo.attr(‘complete’) ? “done” :”” %&gt;” &gt;Very common, but tricky and critical problem for MVC.CanJS has a non-leaking global store, that allows it to solve the 2 ‘instance’ problem without permanently storing all model instances.
  16. All controls are torn down, when all controls are torn down, all event handlers are unbound. When an model instances event handlers are unbound, it’s removed from the store.If you don’t understand this, that’s ok … the big take away is that it’s pretty much impossible to make a leaking CanJS app … You bind and forget ….
  17. Set out to make CanJS the best documented library.Awesome overview page with it’s sweet navigation, underlying docs for every function, method, attribute, and demo applications for each component.Annotated SourceAnd hire us for training, support, or development
  18. deep bindingthe flexibility to switch between libraries without losing all your skills and even some of your (code)
  19. Hello, I&apos;m Justin Meyer from BitoviI&apos;m very proud that this is the second time Bitovi (formerly Jupiter) has sponsered JSConfThis year it comes at an important time for us. Not only are we announcing the rebranding at this conference (we are Bitovi now), we are releasing thenext version of JavaScriptMVC&apos;s MVC parts called CanJS.In this talk, I&apos;ll introduce what&apos;s inside CanJS and talk about why, despite a lot of strong competition, we think CanJS is the best MVC library on the market.