replace new function pattern with IIFE and fixes errors in example code

This commit is contained in:
Keenan Lidral-Porter 2014-12-07 13:19:02 -08:00
parent 4d3430bf2b
commit e690134478
4 changed files with 14 additions and 14 deletions

View file

@ -64,17 +64,17 @@ The example below shows how to use a SubtreeDirective object to create a static
var app = {}
//here's an example plugin that determines whether data has changes.
//in this case, it simply assume data has changed the first time, and never changes after that.
app.bindOnce = new function() {
//in this case, it simply assumes data has changed the first time, and never changes after that.
app.bindOnce = (function() {
var cache = {}
function(view) {
return function(view) {
if (!cache[view.toString()]) {
cache[view.toString()] = true
return view()
}
else return {subtree: "retain"}
}
}
}())
//here's the view
app.view = function() {