We can do better
other languages have rich sets of
tools and patterns, we can too!
Slide 5
Slide 5 text
No content
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
No content
Slide 8
Slide 8 text
Models
var Person = Backbone.Model.extend({
sayName: function(){
return this.get('name');
}
});
var andy = new Person({
name: 'Andy'
});
andy.sayName(); // => 'Andy'
Slide 9
Slide 9 text
Collections
var People = Backbone.Collection.extend({
sayNames: function(){
return this.map(function(model){
return model.get('name');
}).join(', ');
}
});
my-view.js
define(function(require){
var templateFn = require('hbs!path/to/tpl');
// View now has access to compiled template
// function
});
post-template.hbs
{{title}}
...etc
Slide 32
Slide 32 text
my-view.js
define(function(require){
var templateFn = require('hbs!path/to/tpl');
// View now has access to compiled template
// function
});
post-template.hbs
{{title}}
...etc
Slide 33
Slide 33 text
Handy Patterns
Slide 34
Slide 34 text
Mediator
A central object to publish and
subscribe to global events